use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoMap method getPropertyOrElse.
public final Object getPropertyOrElse(String fullName, Object elseValue) throws UserException {
waitForResult();
Property p = null;
if (msgPointer != null) {
p = msgPointer.getProperty(fullName);
} else {
p = inDoc.getProperty(fullName);
}
if (p == null) {
return elseValue;
}
if (p.getType().equals(Property.SELECTION_PROPERTY)) {
if (p.getSelected() != null) {
return p.getSelected().getValue();
} else {
return null;
}
}
return p.getTypedValue();
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class FileMap method setMessage.
public void setMessage(Object o) throws MappableException {
if (o instanceof Message) {
Message arrraymessage = (Message) o;
if (!arrraymessage.getType().equals(Message.MSG_TYPE_ARRAY)) {
throw new MappableException("SetMssage only accepts array message");
}
for (Message m : arrraymessage.getElements()) {
FileLineMap fileLineMap = new FileLineMap();
fileLineMap.setSeparator(separator);
for (Property p : m.getAllProperties()) {
fileLineMap.setColumn(p.getTypedValue().toString());
}
setLine(fileLineMap);
}
} else if (o instanceof List) {
@SuppressWarnings("rawtypes") List maps = (List) o;
for (Object mapobject : maps) {
if (mapobject instanceof com.dexels.navajo.adapter.navajomap.MessageMap) {
com.dexels.navajo.adapter.navajomap.MessageMap map = (com.dexels.navajo.adapter.navajomap.MessageMap) mapobject;
FileLineMap fileLineMap = new FileLineMap();
fileLineMap.setSeparator(separator);
for (Property p : map.getMsg().getAllProperties()) {
if (p.getName().equals("__id")) {
continue;
}
if (p.getTypedValue() != null) {
fileLineMap.setColumn(p.getTypedValue().toString());
} else {
fileLineMap.setColumn("");
}
}
setLine(fileLineMap);
}
}
} else {
throw new MappableException("SetMessage only accepts array message or List, but got a " + o.getClass());
}
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoMap method processSuppressedProperties.
private final void processSuppressedProperties(Message m) {
Iterator<Property> allProps = new ArrayList<Property>(m.getAllProperties()).iterator();
while (allProps.hasNext()) {
Property p = allProps.next();
if (isPropertyInList(p, this.suppressProperties, m.getType().equals(Message.MSG_TYPE_ARRAY_ELEMENT))) {
m.removeProperty(p);
}
}
Iterator<Message> subMessages = m.getAllMessages().iterator();
while (subMessages.hasNext()) {
processSuppressedProperties(subMessages.next());
}
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoMap method getSelections.
public OptionMap[] getSelections() throws UserException {
if (selectionPointer == null) {
throw new UserException(-1, "Set selectionPointer first.");
}
Property p = getPropertyObject(selectionPointer);
if (!p.getType().equals(Property.SELECTION_PROPERTY)) {
throw new UserException(-1, "selections only supported for selection properties");
}
List<Selection> all = p.getAllSelections();
OptionMap[] om = new OptionMap[all.size()];
for (int i = 0; i < all.size(); i++) {
Selection s = all.get(i);
om[i] = new OptionMap();
om[i].setOptionName(s.getName());
om[i].setOptionValue(s.getValue());
om[i].setOptionSelected(s.isSelected());
}
return om;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoMap method processPropertyDirections.
private final void processPropertyDirections(Message m) {
Iterator<Property> allProps = m.getAllProperties().iterator();
while (allProps.hasNext()) {
Property p = allProps.next();
if (isPropertyInList(p, this.outputProperties, m.getType().equals(Message.MSG_TYPE_ARRAY_ELEMENT))) {
p.setDirection(Property.DIR_OUT);
} else if (isPropertyInList(p, this.inputProperties, m.getType().equals(Message.MSG_TYPE_ARRAY_ELEMENT))) {
p.setDirection(Property.DIR_IN);
}
}
Iterator<Message> subMessages = m.getAllMessages().iterator();
while (subMessages.hasNext()) {
processPropertyDirections(subMessages.next());
}
}
Aggregations