if (fieldDataNodeList.size() == 0){
continue;
}
UUID fieldId = dataAccessFactory.createUUID(XMLUtil.getSingleNodeTextContent(fieldNode, "id"));
Field field = template.getField(fieldId);
if(field == null){
continue;
}
if(field.getType().equals(Type.t_selection)){
if(field.getDataType().equals(DataType.dt_single)){
this.setSingleSelection(fieldId, dataAccessFactory.createUUID(fieldDataNodeList.get(0).getTextContent()));
}
else if(field.getDataType().equals(DataType.dt_multiple)){
Set<UUID> fieldDataSet = new LinkedHashSet<UUID>();
for(Node fieldDataNode : fieldDataNodeList){
fieldDataSet.add(dataAccessFactory.createUUID(fieldDataNode.getTextContent()));
}
this.setMultiSelection(fieldId, fieldDataSet.toArray(new UUID[fieldDataSet.size()]));
}
}
else if(field.getType().equals(Type.t_reference)){
if (field.getDataType().equals(DataType.dt_single)){
this.setSingleReference(fieldId, dataAccessFactory.createUUID(fieldDataNodeList.get(0).getTextContent()));
}
else if(field.getDataType().equals(DataType.dt_multiple)){
Set<UUID> fieldDataSet = new LinkedHashSet<UUID>();
for(Node fieldDataNode : fieldDataNodeList){
fieldDataSet.add(dataAccessFactory.createUUID(fieldDataNode.getTextContent()));
}
this.setMultiReference(fieldId, fieldDataSet.toArray(new UUID[fieldDataSet.size()]));
}
}
else if(field.getType().equals(Type.t_attachment)){
Set<UUID> fieldDataSet = new LinkedHashSet<UUID>();
for(Node fieldDataNode : fieldDataNodeList){
fieldDataSet.add(dataAccessFactory.createUUID(fieldDataNode.getTextContent()));
}
this.setAttachments(fieldId, fieldDataSet.toArray(new UUID[fieldDataSet.size()]));
}
else if(field.getType().equals(Type.t_input)){
String fieldData = fieldDataNodeList.get(0).getTextContent();
if(fieldData != null){
if(field.getDataType().equals(DataType.dt_integer)){
this.setInteger(fieldId, Integer.valueOf(fieldData));
}
else if(field.getDataType().equals(DataType.dt_double)){
this.setDouble(fieldId, Double.valueOf(fieldData));
}
else if(field.getDataType().equals(DataType.dt_float)){
this.setFloat(fieldId, Float.valueOf(fieldData));
}
else if(field.getDataType().equals(DataType.dt_long)){
this.setLong(fieldId, Long.valueOf(fieldData));
}
else if(field.getDataType().equals(DataType.dt_timestamp)){
this.setDate(fieldId, Date.valueOf(fieldData));
}
else if(field.getDataType().equals(DataType.dt_string) || field.getDataType().equals(DataType.dt_text)){
this.setString(fieldId, fieldData);
}
}
}
}
List<Node> logNodeList = XMLUtil.getNodes(taskNode, "logs/log");
for(Node logNode : logNodeList){
String logCreateUser = XMLUtil.getSingleNodeTextContent(logNode, "createUser");
if(logCreateUser.equals("script@sogou-inc.com")){
continue;
}
Timestamp logCreateTime = Timestamp.valueOf(XMLUtil.getSingleNodeTextContent(logNode, "createTime"));
UUID actionId = null;
String actionIdStr = XMLUtil.getSingleNodeTextContent(logNode, "actionId");
if(actionIdStr != null){
actionId = DataAccessFactory.getInstance().createUUID(actionIdStr);
}
String actionComment = XMLUtil.getSingleNodeTextContent(logNode, "actionComment");
Map<String, Pair<Object, Object>> baseValueMap = new LinkedHashMap<String, Pair<Object, Object>>();
List<Node> baseValueNodeList = XMLUtil.getNodes(logNode, "baseValues/baseValue");
for(Node baseValueNode : baseValueNodeList){
String base = XMLUtil.getSingleNodeTextContent(baseValueNode, "base");
String previous = XMLUtil.getSingleNodeTextContent(baseValueNode, "previous");
String current = XMLUtil.getSingleNodeTextContent(baseValueNode, "current");
Pair<Object, Object> value = new Pair<Object, Object>();
if(base.equals("id") || base.equals("statusId")){
if(previous != null){
value.setFirst(DataAccessFactory.getInstance().createUUID(previous));
}
if(current != null){
value.setSecond(DataAccessFactory.getInstance().createUUID(current));
}
}
else if(base.equals("createTime") || base.equals("lastModifyTime")){
if(previous != null){
value.setFirst(Timestamp.valueOf(previous));
}
if(current != null){
value.setSecond(Timestamp.valueOf(current));
}
}
else{
value.setFirst(previous);
value.setSecond(current);
}
baseValueMap.put(base, value);
}
Map<UUID, Pair<Object, Object>> extValueMap = new LinkedHashMap<UUID, Pair<Object, Object>>();
List<Node> extValueNodeList = XMLUtil.getNodes(logNode, "extValues/extValue");
for(Node extValueNode : extValueNodeList){
UUID ext = DataAccessFactory.getInstance().createUUID(XMLUtil.getSingleNodeTextContent(extValueNode, "ext"));
String previous = XMLUtil.getSingleNodeTextContent(extValueNode, "previous");
String current = XMLUtil.getSingleNodeTextContent(extValueNode, "current");
Field field = template.getField(ext);
if(field == null){
continue;
}
Pair<Object, Object> value = new Pair<Object, Object>();
if(field.getType().equals(Type.t_selection) || field.getType().equals(Type.t_reference) || field.getType().equals(Type.t_attachment)){
if(field.getDataType() != null && field.getDataType().equals(DataType.dt_single)){
if(previous != null){
value.setFirst(DataAccessFactory.getInstance().createUUID(previous));
}
if(current != null){
value.setSecond(DataAccessFactory.getInstance().createUUID(current));
}
}
else if(field.getDataType() == null || field.getDataType().equals(DataType.dt_multiple)){
if(previous != null){
String[] previousElemArray = previous.split("\\,");
UUID[] previousElemIdArray = new UUID[previousElemArray.length];
for(int i = 0; i < previousElemArray.length; i++){
previousElemIdArray[i] = DataAccessFactory.getInstance().createUUID(previousElemArray[i]);
}
value.setFirst(previousElemIdArray);
}
if(current != null){
String[] currentElemArray = current.split("\\,");
UUID[] currentElemIdArray = new UUID[currentElemArray.length];
for(int i = 0; i < currentElemArray.length; i++){
currentElemIdArray[i] = DataAccessFactory.getInstance().createUUID(currentElemArray[i]);
}
value.setSecond(currentElemIdArray);
}
}
}
else if(field.getType().equals(Type.t_input)){
if(field.getDataType().equals(DataType.dt_integer)){
if(previous != null){
value.setFirst(Integer.valueOf(previous));
}
if(current != null){
value.setSecond(Integer.valueOf(current));
}
}
if(field.getDataType().equals(DataType.dt_long)){
if(previous != null){
value.setFirst(Long.valueOf(previous));
}
if(current != null){
value.setSecond(Long.valueOf(current));
}
}
if(field.getDataType().equals(DataType.dt_float)){
if(previous != null){
value.setFirst(Float.valueOf(previous));
}
if(current != null){
value.setSecond(Float.valueOf(current));
}
}
if(field.getDataType().equals(DataType.dt_double)){
if(previous != null){
value.setFirst(Double.valueOf(previous));
}
if(current != null){
value.setSecond(Double.valueOf(current));
}
}
if(field.getDataType().equals(DataType.dt_timestamp)){
if(previous != null){
value.setFirst(Date.valueOf(previous));
}
if(current != null){
value.setSecond(Date.valueOf(current));
}
}
if(field.getDataType().equals(DataType.dt_string) || field.getDataType().equals(DataType.dt_text)){
value.setFirst(previous);
value.setSecond(current);
}
}