use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BaseMessageImpl method addProperty.
@Override
public final void addProperty(Property q, boolean preferExistingPropertyValue) {
if (this.getType().equals(Message.MSG_TYPE_ARRAY)) {
logger.warn("Adding property {} to array instead of array_element!", q.getName());
}
if (q == null) {
throw new NullPointerException("Message: can not add null property");
}
if (propertyMap == null) {
propertyMap = new TreeMap<>();
}
if (propertyList == null) {
propertyList = new ArrayList<>();
}
BasePropertyImpl p = (BasePropertyImpl) q;
Property oldProperty = propertyMap.get(p.getName());
if (oldProperty == q) {
// ignore
return;
}
if (oldProperty == null) {
propertyList.add(q);
propertyMap.put(p.getName(), p);
p.setParent(this);
} else if (!preferExistingPropertyValue) {
this.removeProperty(oldProperty);
propertyList.add(q);
propertyMap.put(p.getName(), p);
}
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BasePropertyImpl method clone.
@Override
public Object clone() {
Property p = cloneWithoutValue();
p.setName(getName());
if (BINARY_PROPERTY.equals(p.getType())) {
p.setValue(myBinary);
} else {
p.setValue(getValue());
}
return p;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BasePropertyImpl method getEvaluatedValue.
public final Object getEvaluatedValue() {
Operand o;
// No evaluator present.
if (NavajoFactory.getInstance().getExpressionEvaluator() == null) {
return null;
}
try {
try {
if (!EXPRESSION_PROPERTY.equals(getType())) {
throw NavajoFactory.getInstance().createNavajoException("Can only evaluate expression type properties!");
}
try {
o = NavajoFactory.getInstance().getExpressionEvaluator().evaluate(getValue(), getRootDoc(), null, getParentMessage(), null);
evaluatedType = o.type;
return o.value;
} catch (Throwable e) {
logger.info("Exception while evaluating property: {} expression: {}", getFullPropertyName(), getValue());
return null;
}
} catch (NavajoException ex) {
logger.error("Error: ", ex);
if (myParent != null) {
Message pp = myParent.getArrayParentMessage();
if (pp != null && Message.MSG_TYPE_ARRAY.equals(pp.getType())) {
Message def = pp.getDefinitionMessage();
if (def != null) {
Property ppp = def.getProperty(getName());
if (ppp != null) {
evaluatedType = ppp.getType();
return null;
}
}
}
}
evaluatedType = "string";
return null;
}
} catch (Throwable ex1) {
evaluatedType = "string";
return null;
}
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BaseNavajoImpl method getProperties.
@Override
public List<Property> getProperties(String s) {
List<Property> props = new ArrayList<>();
Property prop = null;
List<Message> messages = null;
String property = null;
Message message = null;
StringTokenizer tok = new StringTokenizer(s, Navajo.MESSAGE_SEPARATOR);
String messageList = "";
int count = tok.countTokens();
for (int i = 0; i < count - 1; i++) {
property = tok.nextToken();
messageList += property;
if ((i + 1) < count - 1)
messageList += Navajo.MESSAGE_SEPARATOR;
}
String realProperty = tok.nextToken();
messages = this.getMessages(messageList);
for (int i = 0; i < messages.size(); i++) {
message = messages.get(i);
prop = message.getProperty(realProperty);
if (prop != null)
props.add(prop);
}
return props;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BirtUtils method createResultSet.
private void createResultSet(Document d, Element odaDataSetTag, Message sourceObject, String service) {
Message first = null;
if (sourceObject == null) {
return;
}
if (sourceObject.getType().equals(Message.MSG_TYPE_ARRAY)) {
first = sourceObject.getMessage(0);
if (first == null) {
return;
}
} else {
first = sourceObject;
}
List<Property> props = first.getAllProperties();
Element listprop = addProperty(d, odaDataSetTag, "list-property", "resultSet", null);
for (int i = 0; i < props.size(); i++) {
Property current = props.get(i);
Element s = d.createElement("structure");
listprop.appendChild(s);
addProperty(d, s, "property", "position", "" + (i + 1));
addProperty(d, s, "property", "name", current.getName());
addProperty(d, s, "property", "nativeName", current.getName());
addProperty(d, s, "property", "dataType", getPropertyType(current, false));
if (Property.BINARY_PROPERTY.equals(current.getType())) {
Element n = (Element) XMLutils.findNode(odaDataSetTag, "computedColumns");
if (n == null) {
n = addProperty(d, odaDataSetTag, "list-property", "computedColumns", null);
}
Element struc = addProperty(d, n, "structure", null, null);
addProperty(d, struc, "property", "name", current.getName() + "_Data");
addProperty(d, struc, "expression", "expression", "importPackage(Packages.org.dexels.utils); Base64.decode(dataSetRow[\"" + current.getName() + "\"])");
addProperty(d, struc, "property", "dataType", "any");
}
}
addProperty(d, odaDataSetTag, "property", "queryText", createArrayMessageQueryText(props, service, sourceObject));
}
Aggregations