List of usage examples for java.util Map get
V get(Object key);
From source file:mvm.rya.indexing.external.ExternalIndexMain.java
public static void main(String[] args) throws Exception { Preconditions.checkArgument(args.length == 6, "java " + ExternalIndexMain.class.getCanonicalName() + " sparqlFile cbinstance cbzk cbuser cbpassword rdfTablePrefix."); final String sparqlFile = args[0]; instStr = args[1];/*from w w w. j ava 2 s . c o m*/ zooStr = args[2]; userStr = args[3]; passStr = args[4]; tablePrefix = args[5]; String queryString = FileUtils.readFileToString(new File(sparqlFile)); // Look for Extra Indexes Instance inst = new ZooKeeperInstance(instStr, zooStr); Connector c = inst.getConnector(userStr, passStr.getBytes()); System.out.println("Searching for Indexes"); Map<String, String> indexTables = Maps.newLinkedHashMap(); for (String table : c.tableOperations().list()) { if (table.startsWith(tablePrefix + "INDEX_")) { Scanner s = c.createScanner(table, new Authorizations()); s.setRange(Range.exact(new Text("~SPARQL"))); for (Entry<Key, Value> e : s) { indexTables.put(table, e.getValue().toString()); } } } List<ExternalTupleSet> index = Lists.newArrayList(); if (indexTables.isEmpty()) { System.out.println("No Index found"); } else { for (String table : indexTables.keySet()) { String indexSparqlString = indexTables.get(table); System.out.println("====================== INDEX FOUND ======================"); System.out.println(" table : " + table); System.out.println(" sparql : "); System.out.println(indexSparqlString); index.add(new AccumuloIndexSet(indexSparqlString, c, table)); } } // Connect to Rya Sail s = getRyaSail(); SailRepository repo = new SailRepository(s); repo.initialize(); // Perform Query CountingTupleQueryResultHandler count = new CountingTupleQueryResultHandler(); SailRepositoryConnection conn; if (index.isEmpty()) { conn = repo.getConnection(); } else { ExternalProcessor processor = new ExternalProcessor(index); Sail processingSail = new ExternalSail(s, processor); SailRepository smartSailRepo = new SailRepository(processingSail); smartSailRepo.initialize(); conn = smartSailRepo.getConnection(); } startTime = System.currentTimeMillis(); lastTime = startTime; System.out.println("Query Started"); conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(count); System.out.println("Count of Results found : " + count.i); System.out.println("Total query time (s) : " + (System.currentTimeMillis() - startTime) / 1000.); }
From source file:junkProducer.java
public static void main(String[] args) throws Exception { // read command line args for a connection to Kafka CommandLineParser parser = new BasicParser(); Options options = getCommonRequiredOptions(); CommandLine cmd = parser.parse(options, args); // create the producer and consumer KafkaDataStore objects Map<String, String> dsConf = getKafkaDataStoreConf(cmd); // dsConf.put("isProducer", "true"); DataStore producerDS = DataStoreFinder.getDataStore(dsConf); // verify that we got back our KafkaDataStore objects properly if (producerDS == null) { throw new Exception("Null producer KafkaDataStore"); }/* www . jav a 2 s .co m*/ // create the schema which creates a topic in Kafka // (only needs to be done once) final String sftName = "junk"; final String sftSchema = "trainStatus:String,trainCode:String,publicMessage:String,direction:String,dtg:Date,*geom:Point:srid=4326"; SimpleFeatureType sft = SimpleFeatureTypes.createType(sftName, sftSchema); // set zkPath to default if not specified String zkPath = (dsConf.get(ZK_PATH) == null) ? "/geomesa/ds/kafka" : dsConf.get(ZK_PATH); SimpleFeatureType preppedOutputSft = KafkaDataStoreHelper.createStreamingSFT(sft, zkPath); // only create the schema if it hasn't been created already if (!Arrays.asList(producerDS.getTypeNames()).contains(sftName)) producerDS.createSchema(preppedOutputSft); // the live consumer must be created before the producer writes features // in order to read streaming data. // i.e. the live consumer will only read data written after its instantiation SimpleFeatureStore producerFS = (SimpleFeatureStore) producerDS.getFeatureSource(sftName); // creates and adds SimpleFeatures to the producer on an interval System.out.println("Writing features to Kafka... refresh GeoServer layer preview to see changes"); addSimpleFeatures(sft, producerFS); System.exit(0); }
From source file:com.jslsolucoes.tagria.doc.generator.DocGenerator.java
public static void main(String[] args) throws IOException { String workspace = args[0];//from w ww. j a v a2 s . c om Map<String, List<Tag>> groupments = new HashMap<>(); String html = FileUtils.readFileToString( new File(workspace + "/tagria-lib/src/main/resources/META-INF/html.tld"), CHARSET); String ajax = FileUtils.readFileToString( new File(workspace + "/tagria-lib/src/main/resources/META-INF/ajax.tld"), CHARSET); XStream xStream = new XStream(); xStream.processAnnotations(Taglib.class); Taglib taglibForHtml = (Taglib) xStream.fromXML(html); Taglib taglibForAjax = (Taglib) xStream.fromXML(ajax); List<Tag> tags = new ArrayList<Tag>(); tags.addAll(taglibForHtml.getTags()); tags.addAll(taglibForAjax.getTags()); for (Tag tag : tags) { List<Tag> groups = groupments.get(tag.getGroup()); if (groups == null) { groupments.put(tag.getGroup(), new ArrayList<>()); } groupments.get(tag.getGroup()).add(tag); StringBuilder template = new StringBuilder( "<%@include file=\"../app/taglibs.jsp\"%> " + "<html:view title=\"{title}\"> " + " <html:panel> " + " <html:panelHead label=\"" + tag.getName() + "\"></html:panelHead> " + " <html:panelBody> " + " <html:tabPanel> " + " <html:tab label=\"{about}\" active=\"true\"> " + " <html:alert state=\"warning\"> " + " " + tag.getDescription() + " " + " </html:alert> " + " </html:tab> " + " <html:tab label=\"{attributes}\"> "); if (CollectionUtils.isEmpty(tag.getAttributes())) { template.append("<html:alert state=\"info\" label=\"{tag.empty.attributes}\"></html:alert>"); } else { template.append("<html:table><html:tableLine>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.attribute\"/></html:tableColumn>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.required\"/></html:tableColumn>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.type\"/></html:tableColumn>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.description\"/></html:tableColumn>" + "</html:tableLine>"); for (Attribute attribute : tag.getAttributes()) { template.append("<html:tableLine>" + "<html:tableColumn>" + attribute.getName() + "</html:tableColumn>" + "<html:tableColumn>" + (attribute.getRequired() == null ? false : true) + "</html:tableColumn>" + "<html:tableColumn>" + attribute.getType() + "</html:tableColumn>" + "<html:tableColumn>" + attribute.getDescription() + "</html:tableColumn>" + "</html:tableLine>"); } template.append("</html:table>"); } template.append(" " + " </html:tab> " + " <html:tab label=\"{demo}\"> " + " " + tag.getExample() + " " + " </html:tab> " + " <html:tab label=\"{source}\"> " + " <html:code> " + " <html:view>" + tag.getExampleEscaped() + "</html:view> " + " </html:code> " + " </html:tab> " + " </html:tabPanel> " + " </html:panelBody> " + " </html:panel> " + " </html:view> "); FileUtils.writeStringToFile(new File( workspace + "/tagria-doc/src/main/webapp/WEB-INF/jsp/component/" + tag.getName() + ".jsp"), template.toString(), CHARSET); } for (List<Tag> values : groupments.values()) { Collections.sort(values, new Comparator<Tag>() { @Override public int compare(Tag o1, Tag o2) { return o1.getName().compareTo(o2.getName()); } }); } StringBuilder menu = new StringBuilder("<html:div cssClass=\"menu\"><html:listGroup>"); for (String key : new TreeSet<String>(groupments.keySet())) { menu.append("<html:listGroupItem><html:collapsable label=\"" + key + "\"><html:listGroup>"); for (Tag tag : groupments.get(key)) { menu.append("<html:listGroupItem><html:link label=\"" + StringUtils.capitalize(tag.getName()) + "\" target=\"conteudo\" url=\"/component/" + tag.getName() + "\"></html:link></html:listGroupItem>"); } menu.append("</html:listGroup></html:collapsable></html:listGroupItem>"); } menu.append("</html:listGroup></html:div>"); File home = new File(workspace + "/tagria-doc/src/main/webapp/WEB-INF/jsp/app/index.jsp"); FileUtils.writeStringToFile(home, FileUtils.readFileToString(home, CHARSET) .replaceAll("<html:div cssClass=\"menu\">[\\s\\S]*?</html:div>", menu.toString()), CHARSET); }
From source file:com.act.lcms.db.analysis.IonDetectionAnalysis.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());/* ww w .j ava 2 s . c o m*/ } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s", e.getMessage()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } File lcmsDir = new File(cl.getOptionValue(OPTION_LCMS_FILE_DIRECTORY)); if (!lcmsDir.isDirectory()) { System.err.format("File at %s is not a directory", lcmsDir.getAbsolutePath()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } String plottingDirectory = cl.getOptionValue(OPTION_PLOTTING_DIR); // Get include and excluse ions from command line Set<String> includeIons; if (cl.hasOption(OPTION_INCLUDE_IONS)) { includeIons = new HashSet<>(Arrays.asList(cl.getOptionValues(OPTION_INCLUDE_IONS))); LOGGER.info("Including ions in search: %s", StringUtils.join(includeIons, ", ")); } else { includeIons = new HashSet<>(); includeIons.add(DEFAULT_ION); } try (DB db = DB.openDBFromCLI(cl)) { ScanFile.insertOrUpdateScanFilesInDirectory(db, lcmsDir); File inputPredictionCorpus = new File(cl.getOptionValue(OPTION_INPUT_PREDICTION_CORPUS)); Map<Double, Set<Pair<String, String>>> massChargeToChemicalAndIon = constructMassChargeToChemicalIonsFromInputFile( inputPredictionCorpus, includeIons, cl.hasOption(OPTION_LIST_OF_INCHIS_INPUT_FILE)); Pair<Set<Pair<String, Double>>, Map<String, Double>> values = constructFakeNameToMassChargeAndSetOfMassChargePairs( massChargeToChemicalAndIon.keySet()); Set<Pair<String, Double>> searchMZs = values.getLeft(); Map<String, Double> chemIDToMassCharge = values.getRight(); LOGGER.info("The number of mass charges are: %d", searchMZs.size()); Map<ScanData.KIND, List<LCMSWell>> wellTypeToLCMSWells = readInputExperimentalSetup(db, new File(cl.getOptionValue(OPTION_INPUT_POSITIVE_AND_NEGATIVE_CONTROL_WELLS_FILE))); // Get experimental setup ie. positive and negative wells from config file List<LCMSWell> positiveWells = wellTypeToLCMSWells.get(ScanData.KIND.POS_SAMPLE); List<LCMSWell> negativeWells = wellTypeToLCMSWells.get(ScanData.KIND.NEG_CONTROL); LOGGER.info("Number of positive wells is: %d", positiveWells.size()); LOGGER.info("Number of negative wells is: %d", negativeWells.size()); HashMap<Integer, Plate> plateCache = new HashMap<>(); String outputPrefix = cl.getOptionValue(OPTION_OUTPUT_PREFIX); IonDetectionAnalysis<LCMSWell> ionDetectionAnalysis = new IonDetectionAnalysis<LCMSWell>(lcmsDir, positiveWells, negativeWells, plottingDirectory, plateCache, searchMZs, db); ionDetectionAnalysis.runLCMSMiningAnalysisAndPlotResults(chemIDToMassCharge, massChargeToChemicalAndIon, outputPrefix, cl.hasOption(OPTION_NON_REPLICATE_ANALYSIS)); } }
From source file:com.conversantmedia.mapreduce.tool.RunJob.java
public static void main(String[] args) throws ToolException, IOException { // Get the base packages from the classpath resource String[] scanPackages = getBasePackagesToScanForDrivers(); // Initialize the reflections object Reflections reflections = initReflections((Object[]) scanPackages); // Search the classpath for Tool and Driver annotations Map<String, DriverMeta> idMap = findAllDrivers(reflections); if (idMap.isEmpty()) { System.out.printf("No drivers found in package(s) [%s]\n", StringUtils.join(scanPackages, ",")); System.exit(0);/* ww w .j a v a 2 s. c o m*/ } // Expects the first argument to be the id of the // tool to run. Otherwise list them all: if (args.length < 1) { outputDriversTable(idMap); System.exit(0); } // Shift off the first (driver id) argument String id = args[0]; args = ArrayUtils.subarray(args, 1, args.length); DriverMeta driverMeta = idMap.get(id); if (driverMeta == null) { if (StringUtils.isNotBlank(id) && !StringUtils.startsWith(id, "-")) { // don't output message if no driver was specified // or if the first arg is an argument such as --conf (from runjob script) System.out.println("No Tool or Driver class found with id [" + id + "]"); } outputDriversTable(idMap); System.exit(1); } // Finally, run the tool runDriver(driverMeta, args); }
From source file:com.green.generate.Generate.java
public static void main(String[] args) throws Exception { // ========== ?? ==================== // ??????/*from ww w .j a v a 2 s . co m*/ // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.thinkgem.jeesite.modules"; String moduleName = "factory"; // ???sys String subModuleName = ""; // ????? String className = "product"; // ??user String classAuthor = "ThinkGem"; // ThinkGem String functionName = "?"; // ?? // ??? Boolean isEnable = false; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; // ? File projectPath = new DefaultResourceLoader().getResource("").getFile(); while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) { projectPath = projectPath.getParentFile(); } logger.info("Project Path: {}", projectPath); // ? String tplPath = StringUtils.replace(projectPath + "/src/main/java/com/thinkgem/jeesite/generate/template", "/", separator); logger.info("Template Path: {}", tplPath); // Java String javaPath = StringUtils.replaceEach( projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." }, new String[] { separator, separator }); logger.info("Java Path: {}", javaPath); // String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator); logger.info("View Path: {}", viewPath); // ??? Configuration cfg = new Configuration(); cfg.setDirectoryForTemplateLoading(new File(tplPath)); // ??? Map<String, String> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); model.put("tableName", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "") + "_" + model.get("className")); model.put("urlPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "") + "/" + model.get("className")); model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+ model.get("urlPrefix")); model.put("permissionPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "") + ":" + model.get("className")); // ? Entity Template template = cfg.getTemplate("entity.ftl"); String content = FreeMarkers.renderTemplate(template, model); String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java"; writeFile(content, filePath); logger.info("Entity: {}", filePath); // ? Dao template = cfg.getTemplate("dao.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java"; writeFile(content, filePath); logger.info("Dao: {}", filePath); // ? Service template = cfg.getTemplate("service.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java"; writeFile(content, filePath); logger.info("Service: {}", filePath); // ? Controller template = cfg.getTemplate("controller.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java"; writeFile(content, filePath); logger.info("Controller: {}", filePath); // ? ViewForm template = cfg.getTemplate("viewForm.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "Form.jsp"; writeFile(content, filePath); logger.info("ViewForm: {}", filePath); // ? ViewList template = cfg.getTemplate("viewList.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "List.jsp"; writeFile(content, filePath); logger.info("ViewList: {}", filePath); logger.info("Generate Success."); }
From source file:com.ourlife.dev.generate.Generate.java
public static void main(String[] args) throws Exception { // ========== ?? ==================== // ??????//from ww w.j a va 2 s.com // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName // ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.ourlife.dev.modules"; String moduleName = "biz"; // ???sys String subModuleName = ""; // ????? String className = "orderLog"; // ??user String classAuthor = "ourlife"; // ourlife String functionName = "?"; // ?? // ??? Boolean isEnable = true; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; // ? File projectPath = new DefaultResourceLoader().getResource("").getFile(); while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) { projectPath = projectPath.getParentFile(); } logger.info("Project Path: {}", projectPath); // ? String tplPath = StringUtils.replace(projectPath + "/src/main/java/com/ourlife/dev/generate/template", "/", separator); logger.info("Template Path: {}", tplPath); // Java String javaPath = StringUtils.replaceEach( projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." }, new String[] { separator, separator }); logger.info("Java Path: {}", javaPath); // String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator); logger.info("View Path: {}", viewPath); // ??? Configuration cfg = new Configuration(); cfg.setDirectoryForTemplateLoading(new File(tplPath)); // ??? Map<String, String> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); model.put("tableName", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "") + "_" + model.get("className")); model.put("urlPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "") + "/" + model.get("className")); model.put("viewPrefix", // StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+ model.get("urlPrefix")); model.put("permissionPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "") + ":" + model.get("className")); // ? Entity Template template = cfg.getTemplate("entity.ftl"); String content = FreeMarkers.renderTemplate(template, model); String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java"; writeFile(content, filePath); logger.info("Entity: {}", filePath); // ? Dao template = cfg.getTemplate("dao.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java"; writeFile(content, filePath); logger.info("Dao: {}", filePath); // ? Service template = cfg.getTemplate("service.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java"; writeFile(content, filePath); logger.info("Service: {}", filePath); // ? Controller template = cfg.getTemplate("controller.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java"; writeFile(content, filePath); logger.info("Controller: {}", filePath); // ? ViewForm template = cfg.getTemplate("viewForm.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "Form.jsp"; writeFile(content, filePath); logger.info("ViewForm: {}", filePath); // ? ViewList template = cfg.getTemplate("viewList.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "List.jsp"; writeFile(content, filePath); logger.info("ViewList: {}", filePath); logger.info("Generate Success."); }
From source file:iarnrodProducer.java
public static void main(String[] args) throws Exception { // read command line args for a connection to Kafka CommandLineParser parser = new BasicParser(); Options options = getCommonRequiredOptions(); CommandLine cmd = parser.parse(options, args); // create the producer and consumer KafkaDataStore objects Map<String, String> dsConf = getKafkaDataStoreConf(cmd); dsConf.put("isProducer", "true"); DataStore producerDS = DataStoreFinder.getDataStore(dsConf); // verify that we got back our KafkaDataStore objects properly if (producerDS == null) { throw new Exception("Null producer KafkaDataStore"); }// w w w . jav a 2 s .c o m // create the schema which creates a topic in Kafka // (only needs to be done once) final String sftName = "iarnrod"; final String sftSchema = "trainStatus:String,trainCode:String,publicMessage:String,direction:String,dtg:Date,*geom:Point:srid=4326"; SimpleFeatureType sft = SimpleFeatureTypes.createType(sftName, sftSchema); // set zkPath to default if not specified String zkPath = (dsConf.get(ZK_PATH) == null) ? "/geomesa/ds/kafka" : dsConf.get(ZK_PATH); SimpleFeatureType preppedOutputSft = KafkaDataStoreHelper.createStreamingSFT(sft, zkPath); // only create the schema if it hasn't been created already if (!Arrays.asList(producerDS.getTypeNames()).contains(sftName)) producerDS.createSchema(preppedOutputSft); // the live consumer must be created before the producer writes features // in order to read streaming data. // i.e. the live consumer will only read data written after its instantiation SimpleFeatureStore producerFS = (SimpleFeatureStore) producerDS.getFeatureSource(sftName); // creates and adds SimpleFeatures to the producer on an interval System.out.println("Writing features to Kafka... refresh GeoServer layer preview to see changes"); addSimpleFeatures(sft, producerFS); System.exit(0); }
From source file:com.joey.Fujikom.generate.Generate.java
public static void main(String[] args) throws Exception { // ========== ?? ==================== // ??????/*from ww w . ja v a2 s. co m*/ // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.joey.Fujikom.modules"; String moduleName = "factory"; // ???sys String subModuleName = ""; // ????? String className = "product"; // ??user String classAuthor = "ThinkGem"; // ThinkGem String functionName = "?"; // ?? // ??? //Boolean isEnable = false; Boolean isEnable = true; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; // ? File projectPath = new DefaultResourceLoader().getResource("").getFile(); while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) { projectPath = projectPath.getParentFile(); } logger.info("Project Path: {}", projectPath); // ? String tplPath = StringUtils.replace(projectPath + "/src/main/java/com/thinkgem/Fujikom/generate/template", "/", separator); logger.info("Template Path: {}", tplPath); // Java String javaPath = StringUtils.replaceEach( projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." }, new String[] { separator, separator }); logger.info("Java Path: {}", javaPath); // String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator); logger.info("View Path: {}", viewPath); // ??? Configuration cfg = new Configuration(); cfg.setDefaultEncoding("UTF-8"); cfg.setDirectoryForTemplateLoading(new File(tplPath)); // ??? Map<String, String> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); model.put("tableName", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "") + "_" + model.get("className")); model.put("urlPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "") + "/" + model.get("className")); model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+ model.get("urlPrefix")); model.put("permissionPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "") + ":" + model.get("className")); // ? Entity Template template = cfg.getTemplate("entity.ftl"); String content = FreeMarkers.renderTemplate(template, model); String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java"; writeFile(content, filePath); logger.info("Entity: {}", filePath); // ? Dao template = cfg.getTemplate("dao.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java"; writeFile(content, filePath); logger.info("Dao: {}", filePath); // ? Service template = cfg.getTemplate("service.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java"; writeFile(content, filePath); logger.info("Service: {}", filePath); // ? Controller template = cfg.getTemplate("controller.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java"; writeFile(content, filePath); logger.info("Controller: {}", filePath); // ? ViewForm template = cfg.getTemplate("viewForm.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "Form.jsp"; writeFile(content, filePath); logger.info("ViewForm: {}", filePath); // ? ViewList template = cfg.getTemplate("viewList.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "List.jsp"; writeFile(content, filePath); logger.info("ViewList: {}", filePath); logger.info("Generate Success."); }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step2FillWithRetrievedResults.java
public static void main(String[] args) throws IOException { // input dir - list of xml query containers File inputDir = new File(args[0]); // retrieved results from Technion // ltr-50queries-100docs.txt File ltr = new File(args[1]); // output dir File outputDir = new File(args[2]); if (!outputDir.exists()) { outputDir.mkdirs();//w w w. jav a2s .c o m } // load the query containers first (into map: id + container) Map<String, QueryResultContainer> queryResults = new HashMap<>(); for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { System.out.println(f); QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); queryResults.put(queryResultContainer.qID, queryResultContainer); } // iterate over IR results for (String line : FileUtils.readLines(ltr)) { String[] split = line.split("\\s+"); Integer origQueryId = Integer.valueOf(split[0]); String clueWebID = split[2]; Integer rank = Integer.valueOf(split[3]); double score = Double.valueOf(split[4]); String additionalInfo = split[5]; // get the container for this result QueryResultContainer container = queryResults.get(origQueryId.toString()); if (container != null) { // add new result QueryResultContainer.SingleRankedResult result = new QueryResultContainer.SingleRankedResult(); result.clueWebID = clueWebID; result.rank = rank; result.score = score; result.additionalInfo = additionalInfo; if (container.rankedResults == null) { container.rankedResults = new ArrayList<>(); } container.rankedResults.add(result); } } // save all containers to the output dir for (QueryResultContainer queryResultContainer : queryResults.values()) { File outputFile = new File(outputDir, queryResultContainer.qID + ".xml"); FileUtils.writeStringToFile(outputFile, queryResultContainer.toXML(), "utf-8"); System.out.println("Finished " + outputFile); } }