use of org.openforis.idm.model.State in project collect by openforis.
the class DataMarshaller method writeField.
private void writeField(XmlSerializer serializer, Attribute<?, ?> attr, int fieldIdx) throws IOException {
Field<?> fld = attr.getField(fieldIdx);
if (fld.hasData()) {
FieldDefinition<?> fldDefn = fld.getDefinition();
String name = fldDefn.getName();
serializer.startTag(null, name);
Object val = fld.getValue();
if (StringUtils.isNotBlank(fld.getRemarks())) {
serializer.attribute(null, REMARKS_ATTRIBUTE, fld.getRemarks());
}
if (fld.getSymbol() != null) {
serializer.attribute(null, SYMBOL_ATTRIBUTE, fld.getSymbol().toString());
}
State state = fld.getState();
int stateInt = state.intValue();
if (stateInt > 0) {
serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(stateInt));
}
if (val != null) {
String valStr = val.toString();
serializer.text(valStr);
}
serializer.endTag(null, name);
}
}
use of org.openforis.idm.model.State in project collect by openforis.
the class DataMarshaller method writeEmptyNodes.
/**
* Writes empty nodes child of an entity if there is a node state specified.
*
* @param serializer
* @param entity
* @throws IOException
*/
private void writeEmptyNodes(XmlSerializer serializer, Entity entity) throws IOException {
EntityDefinition defn = entity.getDefinition();
List<NodeDefinition> childDefns = defn.getChildDefinitions();
for (NodeDefinition childDefn : childDefns) {
if (entity.getCount(childDefn) == 0) {
State childState = entity.getChildState(childDefn);
int childStateInt = childState.intValue();
if (childStateInt > 0) {
String childName = childDefn.getName();
serializer.startTag(null, childName);
serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(childStateInt));
serializer.endTag(null, childName);
}
}
}
}
use of org.openforis.idm.model.State in project collect by openforis.
the class DataMarshaller method writeState.
private void writeState(XmlSerializer serializer, Node<?> node) throws IOException {
Entity parent = node.getParent();
if (parent != null) {
State s = parent.getChildState(node.getDefinition());
int state = s.intValue();
if (state > 0) {
serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(state));
}
}
}
Aggregations