use of com.dexels.navajo.document.navascript.tags.FieldTag in project navajo by Dexels.
the class NS3ToNSXML method parseInnerBody.
private List<NS3Compatible> parseInnerBody(NS3Compatible parent, XMLElement currentXML) throws Exception {
currentXML.setAttribute("PROCESSED", "true");
List<NS3Compatible> bodyElts = new ArrayList<>();
Vector<XMLElement> children = currentXML.getChildren();
for (XMLElement child : children) {
String name = child.getName();
String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
if (name.equals("Print")) {
DebugTag pt = parsePrint(parent, child);
bodyElts.add(pt);
}
if (name.equals("Log")) {
LogTag pt = parseLog(parent, child);
bodyElts.add(pt);
}
if (name.equals("Property")) {
NS3Compatible pt = parseProperty(parent, child);
bodyElts.add(pt);
}
if (name.equals("Option")) {
// Find type of option: name, value or selected
NS3Compatible pt = parseProperty(parent, child);
bodyElts.add(pt);
}
if (name.equals("Map")) {
MapTag mt = parseMap(parent, child);
bodyElts.add(mt);
}
if (name.equals("Var")) {
ParamTag pt = parseVar(parent, child);
bodyElts.add(pt);
}
if (name.equals("Break")) {
BreakTag mt = parseBreak(parent, child);
bodyElts.add(mt);
}
if (name.equals("Include")) {
IncludeTag mt = parseInclude(parent, child);
bodyElts.add(mt);
}
if (name.equals("Message")) {
MessageTag pt = parseMessage(parent, child);
bodyElts.add(pt);
}
if (name.equals("Synchronized")) {
SynchronizedTag st = parseSynchronizedBlock(parent, child);
bodyElts.add(st);
}
if (name.equals("ConditionalEmptyMessage")) {
BlockTag pt = parseConditionalBlock(parent, child, true);
bodyElts.add(pt);
}
if (name.equals("TopLevelStatement")) {
bodyElts.addAll(parseInnerBody(parent, child));
}
if (name.equals("MethodOrSetter")) {
MapTag parentMap = findClosestMapTag(parent, "");
FieldTag ft = parseMethodOrSetter(parentMap, child);
bodyElts.add(ft);
}
if (name.equals("Loop")) {
LoopTag mt = parseLoop(parent, child);
bodyElts.add(mt);
}
}
return bodyElts;
}
use of com.dexels.navajo.document.navascript.tags.FieldTag in project navajo by Dexels.
the class NS3ToNSXML method parsedMappedArrayMessage.
private MapTag parsedMappedArrayMessage(NS3Compatible parent, XMLElement currentXML) throws Exception {
MapTag mapTag = new MapTag(myNavascript);
mapTag.addParent(parent);
Vector<XMLElement> children = currentXML.getChildren();
mapTag.setOldStyleMap(true);
if (parent != null && parent instanceof FieldTag) {
mapTag.setName(((FieldTag) parent).getParent().getObject());
}
boolean hasFilter = false;
for (XMLElement child : children) {
String name = child.getName();
String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
if (name.equals("MsgIdentifier")) {
mapTag.setRefAttribute("[" + content + "]");
}
if (name.equals("TOKEN") && content.equals("filter")) {
hasFilter = true;
}
if (hasFilter && name.equals("Expression")) {
ExpressionFragment ef = new ExpressionFragment();
consumeContent(ef, child);
mapTag.setFilter(ef.consumedFragment());
}
if (name.equals("InnerBody") || name.equals("InnerBodySelection")) {
List<NS3Compatible> innerBodyElements = parseInnerBody(mapTag, child);
for (NS3Compatible ib : innerBodyElements) {
addChildTag(mapTag, ib);
}
}
}
return mapTag;
}
use of com.dexels.navajo.document.navascript.tags.FieldTag in project navajo by Dexels.
the class NS3ToNSXML method parseMapOrMethodArguments.
private void parseMapOrMethodArguments(NS3Compatible parent, XMLElement currentXML) {
Vector<XMLElement> children = currentXML.getChildren();
String key = null;
for (XMLElement child : children) {
String name = child.getName();
String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
if (name.equals("ParamKeyName")) {
key = content;
}
if (name.equals("LiteralOrExpression")) {
String c = null;
if (isLiteral(child)) {
c = parseStringConstant(child);
} else {
c = parseExpression(child);
}
if (key != null) {
if (parent instanceof MapTag) {
((MapTag) parent).addAttributeNameValue(key, c);
}
if (parent instanceof FieldTag) {
((FieldTag) parent).addAttributeNameValue(key, c);
}
}
key = null;
}
}
}
use of com.dexels.navajo.document.navascript.tags.FieldTag in project navajo by Dexels.
the class NS3ToNSXML method parseMethodOrSetter.
private FieldTag parseMethodOrSetter(MapTag parent, XMLElement currentXML) throws Exception {
FieldTag ft = new FieldTag(parent);
ft.setParent(parent);
ft.addParent(parent);
Vector<XMLElement> children = currentXML.getChildren();
for (XMLElement child : children) {
String name = child.getName();
if (name.equals("Conditional")) {
ConditionFragment currentFragment = new ConditionFragment();
consumeContent(currentFragment, child);
ft.setCondition(currentFragment.consumedFragment());
}
if (name.equals("AdapterMethod")) {
parseAdapterMethod(ft, child);
}
if (name.equals("SetterField")) {
parseAdapterField(ft, child);
}
}
return ft;
}
use of com.dexels.navajo.document.navascript.tags.FieldTag in project navajo by Dexels.
the class NS3ToNSXML method parseProperty.
private NS3Compatible parseProperty(NS3Compatible parent, XMLElement currentXML) throws Exception {
currentXML.setAttribute("PROCESSED", "true");
PropertyTag pt = new PropertyTag(myNavascript);
pt.addParent(parent);
Vector<XMLElement> children = currentXML.getChildren();
for (XMLElement child : children) {
String name = child.getName();
String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
if (name.equals("TOKEN")) {
if (content.equals("value")) {
pt.setName("value");
}
if (content.equals("name")) {
pt.setName("name");
}
if (content.equals("selected")) {
pt.setName("selected");
}
}
if (name.equals("Conditional")) {
ConditionFragment currentFragment = new ConditionFragment();
consumeContent(currentFragment, child);
pt.setCondition(currentFragment.consumedFragment());
}
if (name.equals("PropertyName")) {
pt.setName(content);
}
if (name.equals("PropertyArguments")) {
parsePropertyArguments(pt, child);
}
if (name.equals("ConditionalExpressions")) {
List<ExpressionTag> expressions = parseConditionalExpressions(pt, child);
for (ExpressionTag et : expressions) {
pt.addExpression(et);
}
}
if (name.equals("StringConstant")) {
String c = content.replaceAll("\"", "");
ExpressionTag et = new ExpressionTag(myNavascript);
et.setConstant(c);
pt.addExpression(et);
}
if (name.equals("MappedArrayFieldSelection")) {
MapTag maf = parseMappedArrayField(parent, child);
pt.addMap(maf);
}
if (name.equals("MappedArrayMessageSelection")) {
MapTag maf = parsedMappedArrayMessage(parent, child);
pt.addMap(maf);
}
// Use SelectionMap in combination with a param array message to support this construction in navascript XML.
if (name.equals("SelectionArray")) {
// Create param array
ParamTag paramtag = new ParamTag(myNavascript);
paramtag.setType(Message.MSG_TYPE_ARRAY);
paramtag.setName(randomParamName(pt.getName() + "_selections"));
myNavascript.addParam(paramtag);
// Create com.dexels.navajo.adapter.SelectionMap
MapTag mt = new MapTag(myNavascript);
mt.setObject("com.dexels.navajo.adapter.SelectionMap");
mt.setOldStyleMap(true);
FieldTag fieldOptions = new FieldTag(mt);
fieldOptions.setFieldName("options");
fieldOptions.setOldSkool(true);
MapTag mappedOptions = new MapTag(myNavascript);
fieldOptions.addMap(mappedOptions);
mappedOptions.setOldStyleMap(true);
mappedOptions.setRefAttribute("[/@" + paramtag.getName() + "]");
// Add name, value, selected
FieldTag nameField = new FieldTag(mappedOptions);
nameField.setOldSkool(true);
nameField.setFieldName("optionName");
mappedOptions.addField(nameField);
nameField.addExpression(null, "[name]");
FieldTag valueField = new FieldTag(mappedOptions);
valueField.setOldSkool(true);
valueField.setFieldName("optionValue");
mappedOptions.addField(valueField);
valueField.addExpression(null, "[value]");
FieldTag selectedField = new FieldTag(mappedOptions);
selectedField.setOldSkool(true);
selectedField.setFieldName("optionSelected");
mappedOptions.addField(selectedField);
selectedField.addExpression(null, "[selected]");
// add options field to map
mt.addField(fieldOptions);
// add property to selectionmap
mt.addProperty(pt);
MapTag refOptions = new MapTag(myNavascript);
refOptions.setOldStyleMap(true);
refOptions.setRefAttribute("options");
pt.addMap(refOptions);
PropertyTag nameProp = new PropertyTag(myNavascript);
nameProp.setName("name");
nameProp.addExpression(null, "$optionName");
refOptions.addProperty(nameProp);
PropertyTag valueProp = new PropertyTag(myNavascript);
valueProp.setName("value");
valueProp.addExpression(null, "$optionValue");
refOptions.addProperty(valueProp);
PropertyTag selectedProp = new PropertyTag(myNavascript);
selectedProp.setName("selected");
selectedProp.addExpression(null, "$optionSelected");
refOptions.addProperty(selectedProp);
// Fetch the array elements to construct a param array message to store them.
parseSelectionArrayElements(paramtag, mt, child);
// Return the map instead of the property.
return mt;
}
}
return pt;
}
Aggregations