Skip to content

Commit 61dea13

Browse files
committed
TelosysProject improvement
1 parent 0fd85a0 commit 61dea13

File tree

1 file changed

+72
-11
lines changed

1 file changed

+72
-11
lines changed

src/main/java/org/telosys/tools/api/TelosysProject.java

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,42 @@ public final File getBundleFolder(String bundleName) {
150150
return new File(getTelosysToolsCfg().getTemplatesFolderAbsolutePath(bundleName));
151151
}
152152

153+
/**
154+
* Returns all the bundles folders for the current project
155+
* @return
156+
* @since 4.1.0
157+
*/
158+
public final List<File> getBundles() {
159+
BundlesManager bundlesManager = new BundlesManager( getTelosysToolsCfg() );
160+
return bundlesManager.getBundles();
161+
}
162+
163+
/**
164+
* Returns all the names of existing bunles for the current project
165+
* @return
166+
* @since 4.1.0
167+
*/
168+
public final List<String> getBundleNames() {
169+
BundlesManager bundlesManager = new BundlesManager( getTelosysToolsCfg() );
170+
List<String> bundleNames = new LinkedList<>();
171+
for (File file : bundlesManager.getBundles() ) {
172+
bundleNames.add(file.getName());
173+
}
174+
return bundleNames;
175+
}
176+
177+
/**
178+
* Returns true if the bundle folder exists for the given bundle name
179+
* @param bundleName
180+
* @return
181+
* @since 4.1.0
182+
*/
183+
public final boolean bundleFolderExists(String bundleName) {
184+
checkArgumentNotNull(bundleName, "bundleName");
185+
File file = getBundleFolder(bundleName);
186+
return file.exists() && file.isDirectory();
187+
}
188+
153189
/**
154190
* Returns a list of bundles available on the given user's name (on GitHub)
155191
* @param userName the GitHub user name (e.g. "telosys-tools")
@@ -193,34 +229,44 @@ public BundleStatus downloadAndInstallBundle(String userName, String bundleName)
193229
return bm.downloadAndInstallBundle(userName, bundleName);
194230
}
195231

232+
// /**
233+
// * Returns a list containing all the bundles installed for the current project
234+
// * @return
235+
// * @throws TelosysToolsException
236+
// */
237+
// public List<String> getInstalledBundles() throws TelosysToolsException {
238+
// BundlesManager bundlesManager = new BundlesManager( getTelosysToolsCfg() );
239+
// return bundlesManager.getProjectBundlesList();
240+
// }
241+
196242
/**
197-
* Returns a list containing all the bundles installed for the current project
243+
* Returns the 'templates.cfg' file for the given bundle name <br>
244+
* There's no guarantee the returned file exists
245+
* @param bundleName
198246
* @return
199-
* @throws TelosysToolsException
200247
*/
201-
public List<String> getInstalledBundles() throws TelosysToolsException {
202-
BundlesManager bundlesManager = new BundlesManager( getTelosysToolsCfg() );
203-
return bundlesManager.getProjectBundlesList();
248+
public File getBundleConfigFile(String bundleName) {
249+
BundlesManager bm = new BundlesManager( getTelosysToolsCfg() );
250+
return bm.getBundleConfigFile(bundleName);
204251
}
205252

206253
/**
207-
* Returns the 'templates.cfg' File object for the given bundle name <br>
254+
* Returns the 'templates.cfg' file for the given bundle folder <br>
208255
* There's no guarantee the returned file exists
209-
* @param bundleName
256+
* @param bundleFolder
210257
* @return
211258
*/
212-
public File getBundleConfigFile(String bundleName) {
259+
public File getBundleConfigFile(File bundleFolder) {
213260
BundlesManager bm = new BundlesManager( getTelosysToolsCfg() );
214-
return bm.getBundleConfigFile(bundleName);
261+
return bm.getBundleConfigFile(bundleFolder);
215262
}
216263

217264
/**
218265
* Deletes the given bundle
219266
* @param bundleName
220267
* @return true if found and deleted, false if not found
221-
* @throws TelosysToolsException
222268
*/
223-
public boolean deleteBundle(String bundleName) throws TelosysToolsException {
269+
public boolean deleteBundle(String bundleName) {
224270
BundlesManager bm = new BundlesManager( getTelosysToolsCfg() );
225271
return bm.deleteBundle(bundleName);
226272
}
@@ -393,6 +439,21 @@ public final List<File> getModels() {
393439
return DslModelUtil.getModelsInFolder(getModelsFolder());
394440
}
395441

442+
/**
443+
* Returns all the names of existing models for the current project
444+
* @return
445+
* @since 4.1.0
446+
* @return
447+
*/
448+
public final List<String> getModelNames() {
449+
List<String> modelNames = new LinkedList<>();
450+
// Convert files to file names (strings)
451+
for ( File f : getModels() ) {
452+
modelNames.add(f.getName());
453+
}
454+
return modelNames;
455+
}
456+
396457
/**
397458
* Returns the model info file for the given model name
398459
* @param modelName

0 commit comments

Comments
 (0)