/** * Method for invoking subscriptions via the command line * * @param argv command-line arguments, none used yet */ public static void main(String[] argv) { log.info("#### START DELETE: -----" + new Date() + " ----- ####"); String usage = "it.cilea.hku.authority.ScriptRPSubscribe [-t] or nothing to send out subscriptions."; Options options = new Options(); HelpFormatter formatter = new HelpFormatter(); CommandLine line = null; { Option opt = new Option("t", "test", false, "Run test session"); opt.setRequired(false); options.addOption(opt); } { Option opt = new Option("h", "help", false, "Print this help message"); opt.setRequired(false); options.addOption(opt); } try { line = new PosixParser().parse(options, argv); } catch (Exception e) { // automatically generate the help statement formatter.printHelp(usage, e.getMessage(), options, ""); System.exit(1); } if (line.hasOption("h")) { // automatically generate the help statement formatter.printHelp(usage, options); System.exit(1); } boolean test = line.hasOption("t"); if (test) log.setLevel(Level.DEBUG); Context context = null; try { context = new Context(); Researcher researcher = new Researcher(); ApplicationService applicationService = researcher.getApplicationService(); List<CrisComponentsService> serviceComponent = researcher.getAllCrisComponents(); for (CrisComponentsService service : serviceComponent) { for (ICRISComponent component : service.getComponents().values()) { RelationConfiguration relationConfiguration = component.getRelationConfiguration(); if (Item.class.isAssignableFrom(relationConfiguration.getRelationClass())) { Integer key = CrisConstants.getEntityType(component.getTarget()); String query = relationConfiguration.getQuery(); if (!mapRelationFields.containsKey(key)) { List<String> rels = new LinkedList<String>(); rels.add(query); mapRelationFields.put(key, rels); } else { mapRelationFields.get(key).add(query); } } } } processDaily(researcher, applicationService, context, test); } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (context != null && context.isValid()) { // Nothing is actually written context.abort(); } } log.info("#### END: -----" + new Date() + " ----- ####"); System.exit(0); }