diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/option/DeleteCommand.java b/vipra-cmd/src/main/java/de/vipra/cmd/option/DeleteCommand.java index cb6aa3b6ca2d3af471b831633dc4d4793b7544b7..d1d7981a3eb11a85525738c73f6f48d41908f163 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/option/DeleteCommand.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/option/DeleteCommand.java @@ -28,11 +28,18 @@ public class DeleteCommand implements Command { private DatabaseService<ProcessedArticle> dbArticles; private Filebase filebase; - public DeleteCommand(String[] strings) { - addIds(strings); + /** + * Creates a new delete command. Use {@link DeleteCommand#run()} to run this + * command. + * + * @param ids + * array of ids to be used for deletion. + */ + public DeleteCommand(String[] ids) { + addIds(ids); } - private void addIds(String[] strings) { + public void addIds(String[] strings) { for (String str : strings) { if (str.contains(File.pathSeparator)) { String[] parts = str.split(File.pathSeparator); @@ -42,7 +49,7 @@ public class DeleteCommand implements Command { } } - void deleteEntry(String id) throws ExecutionException { + public void deleteEntry(String id) throws ExecutionException { ArrayList<Exception> errors = new ArrayList<>(); try { @@ -71,7 +78,8 @@ public class DeleteCommand implements Command { public void run() throws ExecutionException { try { config = Config.getConfig(); - dbArticles = DatabaseService.getDatabaseService(config, Constants.Collection.ARTICLES, ProcessedArticle.class); + dbArticles = DatabaseService.getDatabaseService(config, Constants.Collection.ARTICLES, + ProcessedArticle.class); filebase = Filebase.getFilebase(config); } catch (IOException | FilebaseException | ConfigException e) { throw new ExecutionException(e); diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java b/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java index 333f3924e994e2cb2ec15f2f996c0d421e1dc93e..438ffaf63cdc77016912817f73a02e654713c0cf 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java @@ -52,6 +52,15 @@ public class ImportCommand implements Command { private Processor preprocessor; private LDAAnalyzer analyzer; + /** + * Import command to import articles into the database, do topic modeling + * and save everything. Use {@link ImportCommand#run()} to execute this + * command. + * + * @param paths + * Paths to all *.json files containing artiles or folders + * containing *.json files. Not recursive. + */ public ImportCommand(String[] paths) { addPaths(paths); } @@ -62,13 +71,13 @@ public class ImportCommand implements Command { } } - private void addPaths(File[] paths) { + public void addPaths(File[] paths) { for (int i = 0; i < paths.length; i++) { addPath(paths[i]); } } - private void addPath(File file) { + public void addPath(File file) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { @@ -90,7 +99,7 @@ public class ImportCommand implements Command { * @return * @throws ImportException */ - void importArticle(JSONObject obj) throws ImportException { + private void importArticle(JSONObject obj) throws ImportException { out.debug("importing \"" + StringUtils.ellipsize(obj.get("title").toString(), 80) + "\""); ProcessedArticle article = new ProcessedArticle(); article.fromJSON(obj);