Search in sources :

Example 36 with Property

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();
}
Also used : Property(com.dexels.navajo.document.Property)

Example 37 with Property

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());
    }
}
Also used : MappableException(com.dexels.navajo.script.api.MappableException) Message(com.dexels.navajo.document.Message) FileLineMap(com.dexels.navajo.adapter.filemap.FileLineMap) ArrayList(java.util.ArrayList) List(java.util.List) Property(com.dexels.navajo.document.Property)

Example 38 with Property

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());
    }
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property)

Example 39 with Property

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;
}
Also used : Selection(com.dexels.navajo.document.Selection) UserException(com.dexels.navajo.script.api.UserException) Property(com.dexels.navajo.document.Property)

Example 40 with Property

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());
    }
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property)

Aggregations

Property (com.dexels.navajo.document.Property)253 Message (com.dexels.navajo.document.Message)148 Test (org.junit.Test)88 Navajo (com.dexels.navajo.document.Navajo)84 Selection (com.dexels.navajo.document.Selection)36 NavajoException (com.dexels.navajo.document.NavajoException)30 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)17 ArrayList (java.util.ArrayList)17 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)16 Binary (com.dexels.navajo.document.types.Binary)16 UserException (com.dexels.navajo.script.api.UserException)16 Access (com.dexels.navajo.script.api.Access)15 StringWriter (java.io.StringWriter)13 List (java.util.List)11 Operand (com.dexels.navajo.document.Operand)10 MappableException (com.dexels.navajo.script.api.MappableException)9 IOException (java.io.IOException)9 Writer (java.io.Writer)9 StringTokenizer (java.util.StringTokenizer)9 JSONTML (com.dexels.navajo.document.json.JSONTML)8