List of usage examples for org.apache.maven.plugin MojoExecutionException MojoExecutionException
public MojoExecutionException(String message)
MojoExecutionException
exception providing a message
. From source file:com.apelon.akcds.loinc.LoincToEConcepts.java
License:Apache License
public void execute() throws MojoExecutionException { ConsoleUtil.println("LOINC Processing Begins " + new Date().toString()); LOINCReader loincData = null;//from w w w . jav a 2s . c o m LOINCReader mapTo = null; LOINCReader sourceOrg = null; LOINCReader loincMultiData = null; try { super.execute(); if (!inputFileLocation.isDirectory()) { throw new MojoExecutionException( "LoincDataFiles must point to a directory containing the 3 required loinc data files"); } for (File f : inputFileLocation.listFiles()) { if (f.getName().toLowerCase().equals("loincdb.txt")) { loincData = new TxtFileReader(f); } else if (f.getName().toLowerCase().equals("loinc.csv")) { loincData = new CSVFileReader(f); } else if (f.getName().toLowerCase().equals("map_to.csv")) { mapTo = new CSVFileReader(f); } else if (f.getName().toLowerCase().equals("source_organization.csv")) { sourceOrg = new CSVFileReader(f); } else if (f.getName().toLowerCase().endsWith("multi-axial_hierarchy.csv")) { loincMultiData = new CSVFileReader(f); } } if (loincData == null) { throw new MojoExecutionException( "Could not find the loinc data file in " + inputFileLocation.getAbsolutePath()); } if (loincMultiData == null) { throw new MojoExecutionException( "Could not find the multi-axial file in " + inputFileLocation.getAbsolutePath()); } SimpleDateFormat dateReader = new SimpleDateFormat("MMMMMMMMMMMMM yyyy"); //Parse things like "June 2014" Date releaseDate = dateReader.parse(loincData.getReleaseDate()); File binaryOutputFile = new File(outputDirectory, "loincEConcepts.jbin"); dos_ = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(binaryOutputFile))); conceptUtility_ = new EConceptUtility(loincNamespaceBaseSeed_, "LOINC Path", dos_, releaseDate.getTime()); contentVersion_ = new PT_ContentVersion(); pt_SkipAxis_ = new PT_SkipAxis(); pt_SkipClass_ = new PT_SkipClass(); String version = loincData.getVersion(); //String releaseDate = ; fieldMap_ = loincData.getFieldMap(); fieldMapInverse_ = loincData.getFieldMapInverse(); String mapFileName = null; if (version.contains("2.36")) { PropertyType.setSourceVersion(1); mapFileName = "classMappings-2.36.txt"; } else if (version.contains("2.38")) { PropertyType.setSourceVersion(2); mapFileName = "classMappings-2.36.txt"; // Yes, wrong one, never made the file for 2.38 } else if (version.contains("2.40")) { PropertyType.setSourceVersion(3); mapFileName = "classMappings-2.40.txt"; } else if (version.contains("2.44")) { PropertyType.setSourceVersion(4); mapFileName = "classMappings-2.44.txt"; } else if (version.contains("2.46")) { PropertyType.setSourceVersion(4); mapFileName = "classMappings-2.46.txt"; } else if (version.contains("2.48")) { PropertyType.setSourceVersion(4); mapFileName = "classMappings-2.48.txt"; } else if (version.contains("2.50")) { PropertyType.setSourceVersion(5); mapFileName = "classMappings-2.52.txt"; //never did a 2.50, skipped to 2.52 } else if (version.contains("2.52")) { PropertyType.setSourceVersion(6); mapFileName = "classMappings-2.52.txt"; } else { ConsoleUtil.printErrorln("ERROR: UNTESTED VERSION - NO TESTED PROPERTY MAPPING EXISTS!"); PropertyType.setSourceVersion(6); mapFileName = "classMappings-2.52.txt"; } classMapping_ = new NameMap(mapFileName); if (mapTo != null) { String[] line = mapTo.readLine(); while (line != null) { if (line.length > 0) { HashMap<String, String> nestedData = mapToData.get(line[0]); if (nestedData == null) { nestedData = new HashMap<>(); mapToData.put(line[0], nestedData); } if (nestedData.put(line[1], line[2]) != null) { throw new Exception("Oops - " + line[0] + " " + line[1] + " " + line[2]); } } line = mapTo.readLine(); } } initProperties(); ConsoleUtil.println("Loading Metadata"); // Set up a meta-data root concept UUID archRoot = ArchitectonicAuxiliary.Concept.ARCHITECTONIC_ROOT_CONCEPT.getPrimoridalUid(); UUID metaDataRoot = ConverterUUID.createNamespaceUUIDFromString("metadata"); conceptUtility_.createAndStoreMetaDataConcept(metaDataRoot, "LOINC Metadata", false, archRoot, dos_); conceptUtility_.loadMetaDataItems(propertyTypes_, metaDataRoot, dos_); // Load up the propertyType map for speed, perform basic sanity check for (PropertyType pt : propertyTypes_) { for (String propertyName : pt.getPropertyNames()) { if (propertyToPropertyType_.containsKey(propertyName)) { ConsoleUtil .printErrorln("ERROR: Two different property types each contain " + propertyName); } propertyToPropertyType_.put(propertyName, pt); } } if (sourceOrg != null) { EConcept sourceOrgConcept = conceptUtility_.createAndStoreMetaDataConcept("Source Organization", false, metaDataRoot, dos_); String[] line = sourceOrg.readLine(); while (line != null) { //"COPYRIGHT_ID","NAME","COPYRIGHT","TERMS_OF_USE","URL" if (line.length > 0) { EConcept c = conceptUtility_.createConcept(line[0], sourceOrgConcept.getPrimordialUuid()); conceptUtility_.addDescription(c, line[1], DescriptionType.SYNONYM, true, propertyToPropertyType_.get("NAME").getProperty("NAME").getUUID(), null, false); conceptUtility_.addStringAnnotation(c, line[2], propertyToPropertyType_.get("COPYRIGHT").getProperty("COPYRIGHT").getUUID(), false); conceptUtility_.addStringAnnotation(c, line[3], propertyToPropertyType_.get("TERMS_OF_USE").getProperty("TERMS_OF_USE").getUUID(), false); conceptUtility_.addStringAnnotation(c, line[4], propertyToPropertyType_.get("URL").getProperty("URL").getUUID(), false); c.writeExternal(dos_); } line = sourceOrg.readLine(); } } // write this at the end EConcept loincRefset = pt_refsets_.getConcept(PT_Refsets.Refsets.ALL.getProperty()); // The next line of the file is the header. String[] headerFields = loincData.getHeader(); // validate that we are configured to map all properties properly checkForLeftoverPropertyTypes(headerFields); ConsoleUtil.println("Metadata summary:"); for (String s : conceptUtility_.getLoadStats().getSummary()) { ConsoleUtil.println(" " + s); } conceptUtility_.clearLoadStats(); // Root EConcept rootConcept = conceptUtility_.createConcept("LOINC"); conceptUtility_.addDescription(rootConcept, "LOINC", DescriptionType.SYNONYM, true, null, null, false); conceptUtility_.addDescription(rootConcept, "Logical Observation Identifiers Names and Codes", DescriptionType.SYNONYM, false, null, null, false); ConsoleUtil.println("Root concept FSN is 'LOINC' and the UUID is " + rootConcept.getPrimordialUuid()); conceptUtility_.addStringAnnotation(rootConcept, version, contentVersion_.getProperty("Source Version").getUUID(), false); conceptUtility_.addStringAnnotation(rootConcept, loincData.getReleaseDate(), contentVersion_.getProperty("Release Date").getUUID(), false); conceptUtility_.addStringAnnotation(rootConcept, converterResultVersion, contentVersion_.RELEASE.getUUID(), false); conceptUtility_.addStringAnnotation(rootConcept, loaderVersion, contentVersion_.LOADER_VERSION.getUUID(), false); concepts_.put(rootConcept.primordialUuid, rootConcept); // Build up the Class metadata EConcept classConcept = conceptUtility_.createConcept(pt_SkipClass_.getPropertyTypeUUID(), pt_SkipClass_.getPropertyTypeDescription(), rootConcept.primordialUuid); concepts_.put(classConcept.primordialUuid, classConcept); for (String property : pt_SkipClass_.getPropertyNames()) { EConcept temp = conceptUtility_.createConcept(pt_SkipClass_.getProperty(property).getUUID(), property, classConcept.primordialUuid); concepts_.put(temp.primordialUuid, temp); } // And the axis metadata EConcept axisConcept = conceptUtility_.createConcept(pt_SkipAxis_.getPropertyTypeUUID(), pt_SkipAxis_.getPropertyTypeDescription(), rootConcept.primordialUuid); concepts_.put(axisConcept.primordialUuid, axisConcept); for (String property : pt_SkipAxis_.getPropertyNames()) { EConcept temp = conceptUtility_.createConcept(pt_SkipAxis_.getProperty(property).getUUID(), property, axisConcept.primordialUuid); concepts_.put(temp.primordialUuid, temp); } // load the data ConsoleUtil.println("Reading data file into memory."); int dataRows = 0; { String[] line = loincData.readLine(); dataRows++; while (line != null) { if (line.length > 0) { processDataLine(line); } line = loincData.readLine(); dataRows++; if (dataRows % 1000 == 0) { ConsoleUtil.showProgress(); } } } loincData.close(); ConsoleUtil.println("Read " + dataRows + " data lines from file"); ConsoleUtil.println("Processing multi-axial file"); { // header - PATH_TO_ROOT,SEQUENCE,IMMEDIATE_PARENT,CODE,CODE_TEXT int lineCount = 0; String[] line = loincMultiData.readLine(); while (line != null) { lineCount++; if (line.length > 0) { processMultiAxialData(rootConcept.getPrimordialUuid(), line); } line = loincMultiData.readLine(); if (lineCount % 1000 == 0) { ConsoleUtil.showProgress(); } } loincMultiData.close(); ConsoleUtil.println("Read " + lineCount + " data lines from file"); } ConsoleUtil.println("Writing jbin file"); int conCounter = 0; for (EConcept concept : concepts_.values()) { conceptUtility_.addRefsetMember(loincRefset, concept.getPrimordialUuid(), null, true, null); concept.writeExternal(dos_); conCounter++; if (conCounter % 10 == 0) { ConsoleUtil.showProgress(); } if ((conCounter % 10000) == 0) { ConsoleUtil.println("Processed: " + conCounter + " - just completed " + concept.getDescriptions().get(0).getText()); } } ConsoleUtil.println("Processed " + conCounter + " concepts total"); conceptUtility_.storeRefsetConcepts(pt_refsets_, dos_); ConsoleUtil.println("Data Load Summary:"); for (String s : conceptUtility_.getLoadStats().getSummary()) { ConsoleUtil.println(" " + s); } ConsoleUtil.println("Skipped " + skippedDeletedItems + " Loinc codes because they were flagged as DELETED and they had no desriptions."); // this could be removed from final release. Just added to help debug editor problems. ConsoleUtil.println("Dumping UUID Debug File"); ConverterUUID.dump(outputDirectory, "loincUuid"); ConsoleUtil.println("LOINC Processing Completes " + new Date().toString()); ConsoleUtil.writeOutputToFile(new File(outputDirectory, "ConsoleOutput.txt").toPath()); } catch (Exception ex) { throw new MojoExecutionException(ex.getLocalizedMessage(), ex); } finally { if (dos_ != null) { try { dos_.flush(); dos_.close(); loincData.close(); loincMultiData.close(); if (mapTo != null) { mapTo.close(); } if (sourceOrg != null) { sourceOrg.close(); } } catch (IOException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } } } }
From source file:com.apigee.edge.config.mavenplugin.APIProductMojo.java
License:Apache License
/** * Entry point for the mojo./* w ww .j a v a2s . c o m*/ */ public void execute() throws MojoExecutionException, MojoFailureException { if (super.isSkip()) { getLog().info("Skipping"); return; } Logger logger = LoggerFactory.getLogger(APIProductMojo.class); try { init(); if (buildOption == OPTIONS.none) { logger.info("Skipping API Products (default action)"); return; } if (serverProfile.getEnvironment() == null) { throw new MojoExecutionException("Apigee environment not found in profile"); } List products = getOrgConfig(logger, "apiProducts"); if (products == null || products.size() == 0) { logger.info("No API Products found."); return; } doUpdate(products); } catch (MojoFailureException e) { throw e; } catch (RuntimeException e) { throw e; } }
From source file:com.apigee.edge.config.mavenplugin.AppMojo.java
License:Apache License
/** * Entry point for the mojo./*from w w w .jav a 2 s .c om*/ */ public void execute() throws MojoExecutionException, MojoFailureException { if (super.isSkip()) { getLog().info("Skipping"); return; } Logger logger = LoggerFactory.getLogger(AppMojo.class); try { init(); if (buildOption == OPTIONS.none) { logger.info("Skipping Apps (default action)"); return; } if (serverProfile.getEnvironment() == null) { throw new MojoExecutionException("Apigee environment not found in profile"); } Map<String, List<String>> apps = getOrgConfigWithId(logger, "developerApps"); if (apps == null || apps.size() == 0) { logger.info("No developers apps found."); return; } logger.debug(apps.toString()); doUpdate(apps); } catch (MojoFailureException e) { throw e; } catch (RuntimeException e) { throw e; } }
From source file:com.apigee.edge.config.mavenplugin.CacheMojo.java
License:Apache License
/** * Entry point for the mojo.//from w w w. java 2 s .com */ public void execute() throws MojoExecutionException, MojoFailureException { if (super.isSkip()) { getLog().info("Skipping"); return; } Logger logger = LoggerFactory.getLogger(CacheMojo.class); try { init(); if (buildOption == OPTIONS.none) { logger.info("Skipping Caches (default action)"); return; } if (serverProfile.getEnvironment() == null) { throw new MojoExecutionException("Apigee environment not found in profile"); } List caches = getEnvConfig(logger, "caches"); if (caches == null || caches.size() == 0) { logger.info("No cache config found."); return; } doUpdate(caches); } catch (MojoFailureException e) { throw e; } catch (RuntimeException e) { throw e; } }
From source file:com.apigee.edge.config.mavenplugin.DeveloperMojo.java
License:Apache License
/** * Entry point for the mojo.//from ww w . ja v a2s . co m */ public void execute() throws MojoExecutionException, MojoFailureException { if (super.isSkip()) { getLog().info("Skipping"); return; } Logger logger = LoggerFactory.getLogger(DeveloperMojo.class); try { init(); if (buildOption == OPTIONS.none) { logger.info("Skipping Developers (default action)"); return; } if (serverProfile.getEnvironment() == null) { throw new MojoExecutionException("Apigee environment not found in profile"); } List developers = getOrgConfig(logger, "developers"); if (developers == null || developers.size() == 0) { logger.info("No Developers found."); return; } doUpdate(developers); } catch (MojoFailureException e) { throw e; } catch (RuntimeException e) { throw e; } }
From source file:com.apigee.edge.config.mavenplugin.ExportKeysMojo.java
License:Apache License
/** * Entry point for the mojo.//from ww w . ja va 2 s . c om */ public void execute() throws MojoExecutionException, MojoFailureException { if (super.isSkip()) { getLog().info("Skipping"); return; } Logger logger = LoggerFactory.getLogger(ExportKeysMojo.class); try { init(); if (serverProfile.getEnvironment() == null) { throw new MojoExecutionException("Apigee environment not found in profile"); } Map<String, List<String>> apps = getOrgConfigWithId(logger, "developerApps"); if (apps == null || apps.size() == 0) { logger.info("No developers apps found."); return; } logger.debug("Apps:" + apps.toString()); doExport(apps); } catch (MojoFailureException e) { throw e; } catch (RuntimeException e) { throw e; } }
From source file:com.apigee.edge.config.mavenplugin.GatewayAbstractMojo.java
License:Apache License
protected List getAPIConfig(Logger logger, String config, String api) throws MojoExecutionException { File configFile;/* w w w. j a v a2 s .c om*/ String scope = "api" + File.separator + api; /* configDir takes precedence over edge.json */ if (configDir != null && configDir.length() > 0) { configFile = findConfigFile(scope, config); if (configFile == null) { logger.info("Config file " + scope + File.separator + config + ".json not found."); return null; } logger.info("Retrieving config from " + scope + File.separator + config + ".json"); try { return ConfigReader.getAPIConfig(configFile); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } } /* consolidated edge.json in CWD as fallback */ configFile = findConsolidatedConfigFile(); if (configFile == null) { logger.info("No edge.json found."); throw new MojoExecutionException("config file edge.json not found"); } logger.debug("Retrieving config from edge.json"); try { return ConsolidatedConfigReader.getAPIConfig(configFile, api, config); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } }
From source file:com.apigee.edge.config.mavenplugin.GatewayAbstractMojo.java
License:Apache License
protected Set<String> getAPIList(Logger logger) throws MojoExecutionException { File configFile;/* w w w. j a v a2s . c om*/ String scope = configDir + File.separator + "api"; /* configDir takes precedence over edge.json */ if (configDir != null && configDir.length() > 0) { logger.info("Retrieving API list from " + scope); try { return ConfigReader.getAPIList(scope); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } } /* consolidated edge.json in CWD as fallback */ configFile = findConsolidatedConfigFile(); if (configFile == null) { logger.info("No edge.json found."); throw new MojoExecutionException("config file edge.json not found"); } logger.debug("Retrieving config from edge.json"); try { return ConsolidatedConfigReader.getAPIList(configFile); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } }
From source file:com.apigee.edge.config.mavenplugin.GatewayAbstractMojo.java
License:Apache License
protected List getEnvConfig(Logger logger, String config) throws MojoExecutionException { File configFile;//from www .ja v a 2s. c o m String scope = "env" + File.separator + this.buildProfile.getEnvironment(); /* configDir takes precedence over edge.json */ if (configDir != null && configDir.length() > 0) { configFile = findConfigFile(scope, config); if (configFile == null) { logger.info("Config file " + scope + File.separator + config + ".json not found."); return null; } logger.info("Retrieving config from " + scope + File.separator + config + ".json"); try { return ConfigReader.getEnvConfig(this.buildProfile.getEnvironment(), configFile); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } } /* consolidated edge.json in CWD as fallback */ configFile = findConsolidatedConfigFile(); if (configFile == null) { logger.info("No edge.json found."); throw new MojoExecutionException("config file edge.json not found"); } logger.debug("Retrieving config from edge.json"); try { List envConfigs = ConsolidatedConfigReader.getEnvConfig(this.buildProfile.getEnvironment(), configFile, "envConfig", config); return envConfigs; } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } }
From source file:com.apigee.edge.config.mavenplugin.GatewayAbstractMojo.java
License:Apache License
protected List getOrgConfig(Logger logger, String config) throws MojoExecutionException { File configFile;//from w ww . j a v a2 s . co m String scope = "org"; /* configDir takes precedence over edge.json */ if (configDir != null && configDir.length() > 0) { configFile = findConfigFile(scope, config); if (configFile == null) { logger.info("Config file " + scope + File.separator + config + ".json not found."); return null; } logger.info("Retrieving config from " + scope + File.separator + config + ".json"); try { return ConfigReader.getOrgConfig(configFile); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } } /* consolidated edge.json in CWD as fallback */ configFile = findConsolidatedConfigFile(); if (configFile == null) { logger.info("No edge.json found."); throw new MojoExecutionException("config file edge.json not found"); } logger.debug("Retrieving config from edge.json"); try { return ConsolidatedConfigReader.getOrgConfig(configFile, "orgConfig", config); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } }