aboutsummaryrefslogtreecommitdiffstats
path: root/tools/model-generator
diff options
context:
space:
mode:
Diffstat (limited to 'tools/model-generator')
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java62
1 files changed, 27 insertions, 35 deletions
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
index 7e02c7af5..4d2e99b23 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
@@ -34,7 +34,6 @@ import org.apache.commons.lang3.Validate;
import org.onap.policy.apex.auth.clicodegen.CodeGenCliEditorBuilder;
import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor;
import org.onap.policy.apex.auth.clicodegen.EventDeclarationBuilder;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -96,7 +95,7 @@ public class Model2Cli {
public Model2Cli(final String modelFile, final OutputFile outFile, final boolean validate, final String appName) {
Validate.notNull(modelFile, "Model2Cli: given model file name was blank");
Validate.notNull(appName, "Model2Cli: given application name was blank");
-
+
this.modelFile = modelFile;
this.outFile = outFile;
this.appName = appName;
@@ -108,7 +107,6 @@ public class Model2Cli {
*
* @return status of the application execution, 0 for success, positive integer for exit condition (such as help or
* version), negative integer for errors
- * @throws ApexException if any problem occurred in the model
*/
public int runApp() {
final CodeGeneratorCliEditor codeGen = new CodeGeneratorCliEditor();
@@ -118,7 +116,7 @@ public class Model2Cli {
final ApexApiResult result = model.loadFromFile(modelFile);
if (result.isNok()) {
- String message = appName + ": " + result.getMessage();
+ final String message = appName + ": " + result.getMessage();
LOGGER.error(message);
return -1;
}
@@ -130,7 +128,7 @@ public class Model2Cli {
final AxValidationResult val = new AxValidationResult();
policyModel.validate(val);
if (!val.isOk()) {
- String message = "Cannot translate the model. The model is not valid: \n" + val.toString();
+ final String message = "Cannot translate the model. The model is not valid: \n" + val.toString();
LOGGER.error(message);
return -1;
}
@@ -141,6 +139,7 @@ public class Model2Cli {
/**
* Generate the CLI from the model.
+ *
* @param codeGen the code generator
* @param policyModel the policy model
*/
@@ -157,7 +156,7 @@ public class Model2Cli {
final AxArtifactKey key = s.getKey();
codeGen.addSchemaDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- s.getSchemaFlavour(), s.getSchema());
+ s.getSchemaFlavour(), s.getSchema());
}
// 2: tasks
@@ -170,7 +169,7 @@ public class Model2Cli {
final List<ST> contextRefs = getCtxtRefsForTask(codeGen, t);
codeGen.addTaskDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- infields, outfields, logic, parameters, contextRefs);
+ infields, outfields, logic, parameters, contextRefs);
}
// 3: events
@@ -194,16 +193,10 @@ public class Model2Cli {
for (final AxContextAlbum a : policyModel.getAlbums().getAlbumsMap().values()) {
final AxArtifactKey key = a.getKey();
- codeGen.addContextAlbumDeclaration(
- new CodeGenCliEditorBuilder()
- .setName(kig.getName(key))
- .setVersion(kig.getVersion(key))
- .setUuid(kig.getUuid(key))
- .setDescription(kig.getDesc(key))
- .setScope(a.getScope())
- .setWritable(a.isWritable())
- .setSchemaName(kig.getName(a.getItemSchema()))
- .setSchemaVersion(kig.getVersion(a.getItemSchema())));
+ codeGen.addContextAlbumDeclaration(new CodeGenCliEditorBuilder().setName(kig.getName(key))
+ .setVersion(kig.getVersion(key)).setUuid(kig.getUuid(key)).setDescription(kig.getDesc(key))
+ .setScope(a.getScope()).setWritable(a.isWritable()).setSchemaName(kig.getName(a.getItemSchema()))
+ .setSchemaVersion(kig.getVersion(a.getItemSchema())));
}
// 5: policies
@@ -211,12 +204,12 @@ public class Model2Cli {
final AxArtifactKey key = p.getKey();
final List<ST> states = getStatesForPolicy(codeGen, p);
codeGen.addPolicyDefinition(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- p.getTemplate(), p.getFirstState(), states);
+ p.getTemplate(), p.getFirstState(), states);
}
final String out = codeGen.getModel().render();
if (outFile != null) {
- String message = "Error writing output to file " + outFile;
+ final String message = "Error writing output to file " + outFile;
try {
final Writer w = outFile.toWriter();
if (w == null) {
@@ -232,7 +225,7 @@ public class Model2Cli {
} else {
LOGGER.error(out);
}
-
+
return 0;
}
@@ -250,7 +243,7 @@ public class Model2Cli {
final AxReferenceKey fkey = f.getKey();
final ST val = cg.createEventFieldDefinition(kig.getPName(fkey), kig.getPVersion(fkey), kig.getLName(fkey),
- kig.getName(f.getSchema()), kig.getVersion(f.getSchema()), f.getOptional());
+ kig.getName(f.getSchema()), kig.getVersion(f.getSchema()), f.getOptional());
ret.add(val);
}
@@ -271,7 +264,7 @@ public class Model2Cli {
for (final AxArtifactKey ckey : ctxs) {
final ST val = cg.createTaskDefinitionContextRef(kig.getName(tkey), kig.getVersion(tkey), kig.getName(ckey),
- kig.getVersion(ckey));
+ kig.getVersion(ckey));
ret.add(val);
}
@@ -292,7 +285,7 @@ public class Model2Cli {
final AxReferenceKey pkey = p.getKey();
final ST val = cg.createTaskDefinitionParameters(kig.getPName(pkey), kig.getPVersion(pkey),
- kig.getLName(pkey), p.getTaskParameterValue());
+ kig.getLName(pkey), p.getTaskParameterValue());
ret.add(val);
}
@@ -327,7 +320,7 @@ public class Model2Cli {
final AxReferenceKey fkey = f.getKey();
final ST val = cg.createTaskDefinitionOutfields(kig.getPName(fkey), kig.getPVersion(fkey),
- kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
+ kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
ret.add(val);
}
@@ -348,7 +341,7 @@ public class Model2Cli {
final AxReferenceKey fkey = f.getKey();
final ST val = cg.createTaskDefinitionInfields(kig.getPName(fkey), kig.getPVersion(fkey),
- kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
+ kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
ret.add(val);
}
@@ -374,9 +367,8 @@ public class Model2Cli {
final List<ST> ctxRefs = getCtxtRefsForState(cg, st);
final ST val = cg.createPolicyStateDef(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getName(st.getTrigger()), kig.getVersion(st.getTrigger()),
- kig.getName(st.getDefaultTask()), kig.getVersion(st.getDefaultTask()), outputs, tasks,
- tsLogic, finalizerLogics, ctxRefs);
+ kig.getName(st.getTrigger()), kig.getVersion(st.getTrigger()), kig.getName(st.getDefaultTask()),
+ kig.getVersion(st.getDefaultTask()), outputs, tasks, tsLogic, finalizerLogics, ctxRefs);
ret.add(val);
}
@@ -398,7 +390,7 @@ public class Model2Cli {
final AxReferenceKey finkey = fin.getKey();
final ST val = cg.createPolicyStateDefFinalizerLogic(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), kig.getLName(finkey), fin.getLogicFlavour(), fin.getLogic());
+ kig.getLName(skey), kig.getLName(finkey), fin.getLogicFlavour(), fin.getLogic());
ret.add(val);
}
@@ -419,7 +411,7 @@ public class Model2Cli {
for (final AxArtifactKey ctx : ctxs) {
final ST val = cg.createPolicyStateDefContextRef(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), kig.getName(ctx), kig.getVersion(ctx));
+ kig.getLName(skey), kig.getName(ctx), kig.getVersion(ctx));
ret.add(val);
}
@@ -438,7 +430,7 @@ public class Model2Cli {
if (st.checkSetTaskSelectionLogic()) {
final AxTaskSelectionLogic tsl = st.getTaskSelectionLogic();
final ST val = cg.createPolicyStateDefTaskSelLogic(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), tsl.getLogicFlavour(), tsl.getLogic());
+ kig.getLName(skey), tsl.getLogicFlavour(), tsl.getLogic());
return Collections.singletonList(val);
} else {
return Collections.emptyList();
@@ -462,8 +454,8 @@ public class Model2Cli {
final AxReferenceKey trkey = tr.getKey();
final ST val = cg.createPolicyStateTask(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getLName(trkey), kig.getName(tkey), kig.getVersion(tkey),
- tr.getStateTaskOutputType().name(), kig.getLName(tr.getOutput()));
+ kig.getLName(trkey), kig.getName(tkey), kig.getVersion(tkey), tr.getStateTaskOutputType().name(),
+ kig.getLName(tr.getOutput()));
ret.add(val);
}
@@ -485,8 +477,8 @@ public class Model2Cli {
final AxReferenceKey outkey = out.getKey();
final ST val = cg.createPolicyStateOutput(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getLName(outkey), kig.getName(out.getOutgingEvent()),
- kig.getVersion(out.getOutgingEvent()), kig.getLName(out.getNextState()));
+ kig.getLName(outkey), kig.getName(out.getOutgingEvent()), kig.getVersion(out.getOutgingEvent()),
+ kig.getLName(out.getNextState()));
ret.add(val);
}