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

Examples of com.sogou.qadev.service.cynthia.bean.Data


        }
      } else if (field.getType().equals(Type.t_reference)) {
        if (field.getDataType().equals(DataType.dt_single)) {
          UUID dataId = task.getSingleReference(field.getId());
          if (dataId != null) {
            Data data = das.queryData(dataId);
            if (data != null)
              dataMap.put(field.getName(), data.getTitle());
          }
        } else {
          UUID[] dataIdArray = task.getMultiReference(field.getId());
          if (dataIdArray != null && dataIdArray.length > 0) {
            StringBuffer valueStrb = new StringBuffer();
            for (UUID dataId : dataIdArray) {
              Data data = das.queryData(dataId);
              if (data != null) {
                if (valueStrb.length() > 0)
                  valueStrb.append(",");

                valueStrb.append("[").append(data.getTitle())
                    .append("]");
              }
            }

            if (valueStrb.length() > 0)
View Full Code Here


  }
 
  public Data copyData(UUID dataId, UUID templateId,UUID actionId, String actionUser, String actionComment,
      Map<String, Pair<Object, Object>> baseValueMap, Map<UUID, Pair<Object, Object>> extValueMap)
  {
    Data data = queryData(dataId,templateId);
    if(data == null)
      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);
    }
View Full Code Here

   
    return newData;
  }
 
  public Data queryData(UUID dataId){
    Data data = null;
    if (dataStatus.containsKey(dataId)){
      DataAccessEntry<Data> entry = dataStatus.get(dataId);
      if (entry.getAction().equals(DataAccessAction.insert) || entry.getAction().equals(DataAccessAction.update))
        data = entry.getData();
    }else{
View Full Code Here

   * @email: liming@sogou-inc.com
   * @param dataId
   */
  public Data queryData(UUID dataId,UUID templateId)
  {
    Data data = null;
   
    if (dataStatus.containsKey(dataId)){
      DataAccessEntry<Data> entry = dataStatus.get(dataId);
      if (entry.getAction().equals(DataAccessAction.insert) || entry.getAction().equals(DataAccessAction.update))
        data = entry.getData();
View Full Code Here

          continue;
        if (bugTemplate == null) {
          String[] valueArr = value.split(",");
          if (valueArr != null && valueArr.length > 0) {
            try {
              Data data  = das.queryData(DataAccessFactory.getInstance().createUUID(valueArr[0]));
              if (data != null) {
                bugTemplate = das.queryTemplate(data.getTemplateId());
              }
            } catch (Exception e) {
            }
          }
        }
View Full Code Here

   * @return
   * @see com.sogou.qadev.service.cynthia.service.DataFilter#queryData(com.sogou.qadev.service.cynthia.bean.UUID)
   */
  public Data queryData(UUID id)
  {
    Data data = this.getDataAccessSession().queryData(id);
    if(data != null && !this.getDataAccessSession().checkUserPrivilege(data, DataAccessAction.read))
      data = null;
    return data;
  }
View Full Code Here

      return null;
    }
    Connection conn = null;
    Statement stat = null;
    ResultSet rs = null;
    Data data = null;

    try
    {
      List<String> queryFieldList = new ArrayList<String>();
      Map<String, String> whereFieldsMap = new HashMap<String, String>();
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

   */
  public Data queryData(UUID dataId,UUID templateId){
    Connection conn = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;
    Data data = null;
    try
    {
      String tableName = TableRuleManager.getInstance().getDataTableName(templateId);
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT * FROM " + tableName + " WHERE id = ? and is_valid=?");
View Full Code Here

    Set<Stat> allStatSet = new LinkedHashSet<Stat>();
   
    for(UUID dataId : dataIdArray)
    {
      Data data = das.queryData(dataId);
      if(data == null)
        continue;

      Template template = das.queryTemplate(data.getTemplateId());
      if(template == null)
        continue;

      if(nodeStatusSet.contains(template.getId() + "|" + data.getStatusId()))
        continue;

      nodeStatusSet.add(template.getId() + "|" + data.getStatusId());

      Flow flow = das.queryFlow(template.getFlowId());
      if(flow == null)
        continue;
      boolean isEditAllow = flow.isEditActionAllow(das.getUsername(), template.getId(), data.getAssignUsername(), data.getActionUser());

      if(isEditAllow){//具有编辑权限的人可以批量修改状态
        Stat[] allStats = flow.getStats();
        allStatSet.addAll(Arrays.asList(allStats));
      }
View Full Code Here

TOP

Related Classes of com.sogou.qadev.service.cynthia.bean.Data

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.