Package com.sogou.qadev.service.cynthia.bean.impl

Examples of com.sogou.qadev.service.cynthia.bean.impl.DataImpl


    if (template == null)
      return null;

    UUID dataId = DataAccessFactory.getInstance().newUUID("DATA");
    newUUIDTable.put(dataId, false);
    DataImpl data = new DataImpl(dataId, templateId, getUsername(), new Timestamp(System.currentTimeMillis()));

    return data;
  }
View Full Code Here


      return null;
   
    UUID newDataId = DataAccessFactory.getInstance().newUUID("DATA");
    newUUIDTable.put(newDataId, false);
   
    DataImpl newData = new DataImpl(newDataId, data.getTemplateId(), data.getCreateUsername(), data.getCreateTime());
   
    //set title
    if(baseValueMap != null && baseValueMap.get("title") != null)
      newData.setTitle((String)baseValueMap.get("title").getSecond());
    else
      newData.setTitle(data.getTitle());
   
    //set description
    if(baseValueMap != null && baseValueMap.get("description") != null)
      newData.setDescription((String)baseValueMap.get("description").getSecond());
    else
      newData.setDescription(data.getDescription());
   
    //set assignUser
    if(baseValueMap != null && baseValueMap.get("assignUser") != null)
      newData.setAssignUsername((String)baseValueMap.get("assignUser").getSecond());
    else
      newData.setAssignUsername(data.getAssignUsername());
   
    //set lastModifyTime
    newData.setLastModifyTime(new Timestamp(System.currentTimeMillis()));
   
    //set statusId
    if(baseValueMap != null && baseValueMap.get("statusId") != null)
      newData.setStatusId((UUID)baseValueMap.get("statusId").getSecond());
    else
      newData.setStatusId(data.getStatusId());
   
    //set fieldId value
    UUID[] fieldIdArray = data.getValidFieldIds();
    if(fieldIdArray != null)
    {
      for(UUID fieldId : fieldIdArray)
        newData.setObject(fieldId, data.getObject(fieldId));
    }
   
    if(extValueMap != null)
    {
      for(UUID fieldId : extValueMap.keySet())
        newData.setObject(fieldId, extValueMap.get(fieldId).getSecond());
    }
   
    //add old changeLog
    ChangeLog[] logArray = data.getChangeLogs();
    if(logArray != null)
    {
      for(ChangeLog log : logArray)
        newData.addChangeLog(log);
    }
   
    //set new changeLog
    newData.setObject("logActionId", actionId);
    newData.setObject("logCreateUser", actionUser);
    newData.setObject("logActionComment", actionComment);
    newData.setObject("logBaseValueMap", baseValueMap);
    newData.setObject("logExtValueMap", extValueMap);
   
    return newData;
  }
View Full Code Here

    Map<UUID, Template> allTemplateMap = new HashMap<UUID, Template>();
    Map<UUID, Map<String, String>> templateFieldNameMap = new HashMap<UUID, Map<String,String>>();

    for (Map<String, String> colValueMap : colValueMapList) {
      Data data = new DataImpl();
      UUID dataId = DataAccessFactory.getInstance().createUUID(colValueMap.get("id"));
      UUID templateId = DataAccessFactory.getInstance().createUUID(colValueMap.get("templateId"));

      Map<UUID, Object> objectMapUUID = new HashMap<UUID, Object>();
      Map<String, Object> objectMapName = new HashMap<String, Object>();

      data.setId(dataId);
      data.setTemplateId(templateId);
      data.setTemplateTypeId(DataAccessFactory.getInstance().createUUID(colValueMap.get("templateTypeId")));
      data.setTitle(colValueMap.get("title"));
      data.setDescription(colValueMap.get("description"));
      data.setCreateUser(colValueMap.get("createUser"));
      data.setCreateTime(colValueMap.get("createTime") == null ? null:Timestamp.valueOf(colValueMap.get("createTime")));
      data.setLastModifyTime(colValueMap.get("lastModifyTime") == null ? null : Timestamp.valueOf(colValueMap.get("lastModifyTime")));
      data.setAssignUser(colValueMap.get("assignUser"));
      data.setStatusId(DataAccessFactory.getInstance().createUUID(colValueMap.get("statusId")));

      if (allTemplateMap.get(templateId) == null) {
        Template template = TemplateCache.getInstance().get(templateId);
        if (template != null) {
          allTemplateMap.put(templateId, template);
        }
      }

      Template template = allTemplateMap.get(templateId);

      for (String colName : colValueMap.keySet()) {
        Field validField = null;
        try {
          if (colName.startsWith("field") && colValueMap.get(colName) != null && colValueMap.get(colName).length() > 0) {

            String fieldIdStr = "";

            if (templateFieldNameCache == null ) {
              if (templateFieldNameMap.get(templateId) == null) {
                Map<String, String> fieldNameMap = new FieldNameAccessSessionMySQL().queryTemplateFieldMap(templateId.getValue());
                templateFieldNameMap.put(templateId, fieldNameMap);
              }
              fieldIdStr = templateFieldNameMap.get(templateId).get(colName);
            }else {
              fieldIdStr = templateFieldNameCache.get(colName);
            }

            UUID fieldId = DataAccessFactory.getInstance().createUUID(fieldIdStr);

            validField = template.getField(fieldId);

            if (validField == null) {
//              System.out.println("can not find field in assembleData ,fieldIdStr :" + fieldIdStr );
              continue;
            }
           
            if (validField.getType().equals(Type.t_selection))
            {
              if (validField.getDataType().equals(DataType.dt_single))
              {
                UUID dataValidId = DataAccessFactory.getInstance().createUUID(colValueMap.get(colName));
                objectMapUUID.put(fieldId, dataValidId);
                objectMapName.put(validField.getName(), dataValidId);
              }
              else if (validField.getDataType().equals(DataType.dt_multiple))
              {
                String [] alldatas = colValueMap.get(colName).split(",");
                UUID[] dataValidIds = new UUID[alldatas.length];

                for (int i = 0; i < alldatas.length; i++) {
                  dataValidIds[i] = DataAccessFactory.getInstance().createUUID(alldatas[i]);
                }

                objectMapUUID.put(fieldId, dataValidIds);
                objectMapName.put(validField.getName(), dataValidIds);
              }
            }
            else if (validField.getType().equals(Type.t_reference))
            {
              if (validField.getDataType().equals(DataType.dt_single))
              {
                UUID dataValidId = DataAccessFactory.getInstance().createUUID(colValueMap.get(colName));
                objectMapUUID.put(fieldId, dataValidId);
                objectMapName.put(validField.getName(), dataValidId);
              }
              else if (validField.getDataType().equals(DataType.dt_multiple))
              {
                String [] alldatas = colValueMap.get(colName).split(",");
                UUID[] dataValidIds = new UUID[alldatas.length];

                for (int i = 0; i < alldatas.length; i++) {
                  dataValidIds[i] = DataAccessFactory.getInstance().createUUID(alldatas[i]);
                }

                objectMapUUID.put(fieldId, dataValidIds);
                objectMapName.put(validField.getName(), dataValidIds);
              }
            }
            else if (validField.getType().equals(Type.t_input))
            {
              if (validField.getDataType().equals(DataType.dt_integer))
              {
                objectMapUUID.put(fieldId, Integer.parseInt(colValueMap.get(colName)));
                objectMapName.put(validField.getName(), Integer.parseInt(colValueMap.get(colName)));
              }
              else if (validField.getDataType().equals(DataType.dt_double))
              {
                objectMapUUID.put(fieldId, Double.parseDouble(colValueMap.get(colName)));
                objectMapName.put(validField.getName(), Double.parseDouble(colValueMap.get(colName)));
              }
              else if (validField.getDataType().equals(DataType.dt_float))
              {
                objectMapUUID.put(fieldId, Float.parseFloat(colValueMap.get(colName)));
                objectMapName.put(validField.getName(), Float.parseFloat(colValueMap.get(colName)));
              }
              else if (validField.getDataType().equals(DataType.dt_long))
              {
                objectMapUUID.put(fieldId, Long.parseLong(colValueMap.get(colName)));
                objectMapName.put(validField.getName(), Long.parseLong(colValueMap.get(colName)));
              }
              else if (validField.getDataType().equals(DataType.dt_string) || validField.getDataType().equals(DataType.dt_text) || validField.getDataType().equals(DataType.dt_editor))
              {
                objectMapUUID.put(fieldId, colValueMap.get(colName));
                objectMapName.put(validField.getName(), colValueMap.get(colName));
              }
              else if(validField.getDataType().equals(DataType.dt_timestamp))
              {
                Date date = Date.valueOf(colValueMap.get(colName));
                objectMapUUID.put(fieldId, date);
                objectMapName.put(validField.getName(), date);
              }
            }
            else if (validField.getType().equals(Type.t_attachment))
            {
              String[] alldatas = colValueMap.get(colName).split(",");
              UUID[] dataValidIds = new UUID[alldatas.length];

              for (int i = 0; i < alldatas.length; i++) {
                dataValidIds[i] = DataAccessFactory.getInstance().createUUID(alldatas[i]);
              }

              objectMapUUID.put(fieldId, dataValidIds);
              objectMapName.put(validField.getName(), dataValidIds);
            }
          }
        } catch (Exception e) {
          System.out.println("data assemble error! dataid:" + data.getId().getValue() + " templateid:" + data.getTemplateId().getValue() + " fieldid:" + validField.getId().getValue() );
          e.printStackTrace();
        }
      }

      data.setObjectMapUUID(objectMapUUID);
      data.setObjectMapName(objectMapName);

      if (needLog) {
        List<ChangeLog> changeLogs = new LogAccessSessionMySQL().queryAllChangeLogs(dataId,templateId,templateFieldNameCache);
        data.setChangeLogs(changeLogs);
      }
      allDatas.add(data);
    }

    return allDatas;
View Full Code Here

TOP

Related Classes of com.sogou.qadev.service.cynthia.bean.impl.DataImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.