use of org.asqatasun.referential.creator.exception.InvalidParameterException in project Asqatasun by Asqatasun.
the class CodeGeneratorMojo method execute.
@Override
public void execute() {
try {
isContextValid();
} catch (InvalidParameterException ipe) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ipe);
return;
}
// Initializes engine
VelocityEngine ve = initializeVelocity();
Iterable<CSVRecord> records = getCsv();
if (records == null) {
return;
}
try {
initializeContext();
generate(ve, records);
cleanUpUnusedFiles();
} catch (IOException ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
} catch (ResourceNotFoundException ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParseErrorException ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of org.asqatasun.referential.creator.exception.InvalidParameterException in project Asqatasun by Asqatasun.
the class CodeGeneratorMojo method writeToI18NFile.
private void writeToI18NFile(FileGenerator fg, CSVRecord record, String lang) throws IOException, InvalidParameterException {
Integer themeIndex = Integer.valueOf(record.get(THEME_CODE_COLUMN_NAME));
String theme = record.get(THEME_LABEL_COLUMN_NAME + lang);
String critere;
String critereCode;
String test = record.get(TEST_LABEL_COLUMN_NAME + lang);
String testCode = record.get(TEST_CODE_COLUMN_NAME);
if (isCriterionPresent) {
critere = record.get(CRITERION_LABEL_COLUMN_NAME + lang);
critereCode = record.get(CRITERION_CODE_COLUMN_NAME);
} else {
critere = test;
critereCode = testCode;
}
if (StringUtils.isBlank(theme) || StringUtils.isBlank(critere) || StringUtils.isBlank(critereCode)) {
throw new InvalidParameterException("Your csv file has an empty column");
}
Map themeMap = Collections.singletonMap(themeIndex, theme);
Map critereMap = Collections.singletonMap(critereCode, critere);
Map testMap = Collections.singletonMap(testCode, test);
if (StringUtils.isNotBlank(theme) && StringUtils.isNotBlank(String.valueOf(themeIndex))) {
fg.writei18NFile(themeMap, lang, langSet.first(), "theme");
}
if (StringUtils.isNotBlank(critere) && StringUtils.isNotBlank(critereCode)) {
fg.writei18NFile(critereMap, lang, langSet.first(), "criterion");
}
if (StringUtils.isNotBlank(test) && StringUtils.isNotBlank(testCode)) {
fg.writei18NFile(testMap, lang, langSet.first(), "rule");
}
if (IS_I18N_REFERENTIAL_CREATED == false) {
fg.writei18NFile(null, lang, langSet.first(), "referential");
}
}
Aggregations