* @param fieldNode
* @return
*/
protected Field initFieldNode(Node fieldNode)
{
Field field = null;
try
{
String fieldIdStr = XMLUtil.getSingleNode(fieldNode, "id").getTextContent();
UUID fieldId = DataAccessFactory.getInstance().createUUID(fieldIdStr);
String typeStr = XMLUtil.getSingleNode(fieldNode, "type").getTextContent();
Type type = Type.valueOf(typeStr);
DataType dataType = null;
String dataTypeStr = XMLUtil.getSingleNode(fieldNode, "dataType").getTextContent();
if (dataTypeStr.length() > 0)
dataType = DataType.valueOf(dataTypeStr);
field = new FieldImpl(fieldId, id, type, dataType);
String fieldName = XMLUtil.getSingleNode(fieldNode, "name").getTextContent();
field.setName(fieldName);
String fieldDescription = XMLUtil.getSingleNode(fieldNode, "description").getTextContent();
if (fieldDescription.length() > 0)
field.setDescription(fieldDescription);
String fieldTip = XMLUtil.getSingleNodeTextContent(fieldNode, "fieldTip");
if(fieldTip!=null)
field.setFieldTip(fieldTip);
String fieldSize = XMLUtil.getSingleNodeTextContent(fieldNode, "fieldSize");
if(fieldSize!=null)
field.setFieldSize(fieldSize);
String defaultValue = XMLUtil.getSingleNode(fieldNode, "defaultValue").getTextContent();
if (defaultValue.length() > 0)
field.setDefaultValue(defaultValue);
String controlFieldIdStr = XMLUtil.getSingleNode(fieldNode, "controlFieldId").getTextContent();
if (controlFieldIdStr.length() > 0)
field.setControlFieldId(DataAccessFactory.getInstance().createUUID(controlFieldIdStr));
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
try {
Node controlHiddenFieldIdNode = XMLUtil.getSingleNode(fieldNode, "controlHiddenFieldId");
String controlHiddenFieldIdStr = "";
if (controlHiddenFieldIdNode != null) {
controlHiddenFieldIdStr = controlHiddenFieldIdNode.getTextContent();
}
if (controlHiddenFieldIdStr.length() > 0) {
field.setControlHiddenFieldId(DataAccessFactory.getInstance().createUUID(controlHiddenFieldIdStr));
}
Set<UUID> controlHiddenFieldsSet = new LinkedHashSet<UUID>();
List<Node> controlHiddenFieldsList = XMLUtil.getNodes(fieldNode, "controlHiddenFields/controlHiddenField");
if (controlHiddenFieldsList != null && controlHiddenFieldsList.size() > 0) {
for (Node controlHiddenFieldNode : controlHiddenFieldsList) {
UUID controlHiddenFieldId = DataAccessFactory.getInstance().createUUID(controlHiddenFieldNode.getTextContent());
controlHiddenFieldsSet.add(controlHiddenFieldId);
}
field.setControlHiddenFieldsIds(controlHiddenFieldsSet);
}
Set<UUID> controlHiddenStatesSet = new LinkedHashSet<UUID>();
List<Node> controlHiddenStatesList = XMLUtil.getNodes(fieldNode, "controlHiddenStates/controlHiddenState");
if(controlHiddenStatesList != null && controlHiddenStatesList.size() > 0 ){
for (Node controlHiddenStateNode : controlHiddenStatesList) {
UUID controlHiddenStateId = DataAccessFactory.getInstance().createUUID(controlHiddenStateNode.getTextContent());
controlHiddenStatesSet.add(controlHiddenStateId);
}
field.setControlHiddenStatesIds(controlHiddenStatesSet);
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("init 表单出错");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
Set<Option> optionSet = new LinkedHashSet<Option>();
List<Node> optionNodeList = XMLUtil.getNodes(fieldNode, "options/option");
for (Node optionNode : optionNodeList)
{
String optionIdStr = XMLUtil.getSingleNode(optionNode, "id").getTextContent();
UUID optionId = DataAccessFactory.getInstance().createUUID(optionIdStr);
OptionImpl optionImpl = new OptionImpl(optionId, fieldId);
String optionName = XMLUtil.getSingleNode(optionNode, "name").getTextContent();
optionImpl.setName(optionName);
String optionDescription = XMLUtil.getSingleNode(optionNode, "description").getTextContent();
if (optionDescription.length() > 0)
optionImpl.setDescription(optionDescription);
String controlOptionIdStr = XMLUtil.getSingleNode(optionNode, "controlOptionId").getTextContent();
if (controlOptionIdStr.length() > 0)
optionImpl.setControlOptionId(DataAccessFactory.getInstance().createUUID(controlOptionIdStr));
String forbiddenStr = XMLUtil.getSingleNode(optionNode, "forbidden").getTextContent();
Forbidden forbidden = Forbidden.valueOf(forbiddenStr);
optionImpl.setForbidden(forbidden);
String indexOrderStr = XMLUtil.getSingleNode(optionNode, "indexOrder").getTextContent();
int indexOrder = Integer.parseInt(indexOrderStr);
optionImpl.setIndexOrder(indexOrder);
optionSet.add(optionImpl);
}
field.setOptions(optionSet);
Set<UUID> controlOptionIdSet = new LinkedHashSet<UUID>();
List<Node> controlOptionIdNodeList = XMLUtil.getNodes(fieldNode, "controlOptionIds/controlOptionId");
for (Node controlOptionIdNode : controlOptionIdNodeList)
{
UUID controlOptionId = DataAccessFactory.getInstance().createUUID(controlOptionIdNode.getTextContent());
controlOptionIdSet.add(controlOptionId);
}
field.setControlOptionIds(controlOptionIdSet);
Set<String> controlRoleIdSet = new LinkedHashSet<String>();
List<Node> controlRoleIdNodeList = XMLUtil.getNodes(fieldNode, "controlRoleIds/controlRoleId");
for (Node controlRoleIdNode : controlRoleIdNodeList)
{
controlRoleIdSet.add(controlRoleIdNode.getTextContent());
}
field.setControlRoleIds(controlRoleIdSet);
Set<UUID> actionIdSet = new LinkedHashSet<UUID>();
Set<String> controlActionIdSet = new LinkedHashSet<String>();
List<Node> controlActionIdNodeList = XMLUtil.getNodes(fieldNode, "controlActionIds/controlActionId");
for (Node controlActionIdNode : controlActionIdNodeList)
{
actionIdSet.add(DataAccessFactory.getInstance().createUUID(controlActionIdNode.getTextContent().split("\\_")[0]));
controlActionIdSet.add(controlActionIdNode.getTextContent());
}
field.setControlActionIds(controlActionIdSet);
List<Node> actionIdNodeList = XMLUtil.getNodes(fieldNode, "actionIds/actionId");
for (Node actionIdNode : actionIdNodeList)
actionIdSet.add(DataAccessFactory.getInstance().createUUID(actionIdNode.getTextContent()));
field.setActionIds(actionIdSet);
}catch(Exception e)
{
e.printStackTrace();
}