Package com.sogou.qadev.service.cynthia.factory

Examples of com.sogou.qadev.service.cynthia.factory.DataAccessFactory


   * @param node
   */
  private void init(Node node){
    try {
    Node taskNode = XMLUtil.getSingleNode(node, "task");
    DataAccessFactory dataAccessFactory = DataAccessFactory.getInstance();

    this.id = dataAccessFactory.createUUID(XMLUtil.getSingleNodeTextContent(taskNode, "id"));
    this.templateId = dataAccessFactory.createUUID(XMLUtil.getSingleNodeTextContent(taskNode, "templateId"));
    this.title = XMLUtil.getSingleNodeTextContent(taskNode, "title");
    this.description = XMLUtil.getSingleNodeTextContent(taskNode, "description");
    this.createUser = XMLUtil.getSingleNodeTextContent(taskNode, "createUser");
    this.createTime = Timestamp.valueOf(XMLUtil.getSingleNodeTextContent(taskNode, "createTime"));
    this.assignUser = XMLUtil.getSingleNodeTextContent(taskNode, "assignUser");
    this.lastModifyTime = Timestamp.valueOf(XMLUtil.getSingleNodeTextContent(taskNode, "lastModifyTime"));
    this.statusId = dataAccessFactory.createUUID(XMLUtil.getSingleNodeTextContent(taskNode, "statusId"));

    Template template = TemplateCache.getInstance().get(this.templateId);
    if(template == null){
      throw new RuntimeException();
    }

    this.templateTypeId = template.getTemplateTypeId();

    List<Node> fieldNodeList = XMLUtil.getNodes(taskNode, "fields/field");

    for(Node fieldNode : fieldNodeList){
      List<Node> fieldDataNodeList = XMLUtil.getNodes(fieldNode, "data");
      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)){
View Full Code Here


   * @param root
   * @param createUser
   */
  public FlowImpl(org.w3c.dom.Node root,String createUser){
    this.createUser = createUser;
    DataAccessFactory daf = DataAccessFactory.getInstance();

    Node flowNode = XMLUtil.getSingleNode(root, "flow");

    this.id = daf.createUUID(XMLUtil.getSingleNodeTextContent(flowNode, "id"));
    this.name = XMLUtil.getSingleNodeTextContent(flowNode, "name");
    List<org.w3c.dom.Node> statNodeList = XMLUtil.getNodes(flowNode, "stats/stat");
    for(org.w3c.dom.Node statNode : statNodeList){
      UUID statId = daf.createUUID(XMLUtil.getSingleNodeTextContent(statNode, "id"));
      String statName = XMLUtil.getSingleNodeTextContent(statNode, "name");

      StatImpl statImpl = new StatImpl(statId, this.id);
      statImpl.setName(statName);

      this.statMap.put(statId, statImpl);
    }

    List<org.w3c.dom.Node> actionNodeList = XMLUtil.getNodes(flowNode, "actions/action");
    for(org.w3c.dom.Node actionNode : actionNodeList){
      UUID actionId = daf.createUUID(XMLUtil.getSingleNodeTextContent(actionNode, "id"));
      String actionName = XMLUtil.getSingleNodeTextContent(actionNode, "name");
      UUID beginStatId = daf.createUUID(XMLUtil.getSingleNodeTextContent(actionNode, "startStatId"));
      UUID endStatId = daf.createUUID(XMLUtil.getSingleNodeTextContent(actionNode, "endStatId"));

      ActionImpl actionImpl = new ActionImpl(actionId, this.id);
      actionImpl.setName(actionName);
      actionImpl.setBeginStatId(beginStatId);
      actionImpl.setEndStatId(endStatId);

      this.actionMap.put(actionId, actionImpl);
    }

    List<org.w3c.dom.Node> roleNodeList = XMLUtil.getNodes(flowNode, "roles/role");
    for(org.w3c.dom.Node roleNode : roleNodeList){
      UUID roleId  = daf.createUUID(XMLUtil.getSingleNodeTextContent(roleNode, "id"));
      String roleName = XMLUtil.getSingleNodeTextContent(roleNode, "name");

      RoleImpl roleImpl = new RoleImpl(roleId, this.id);
      roleImpl.setName(roleName);

      this.roleMap.put(roleId, roleImpl);
    }

    List<org.w3c.dom.Node> actionRoleNodeList = XMLUtil.getNodes(flowNode, "actionRoles/actionRole");
    for(org.w3c.dom.Node actionRoleNode : actionRoleNodeList){
      UUID actionId = daf.createUUID(XMLUtil.getSingleNodeTextContent(actionRoleNode, "actionId"));
      UUID roleId = daf.createUUID(XMLUtil.getSingleNodeTextContent(actionRoleNode, "roleId"));

      this.actionRoleSet.add(new ActionRole(actionId, roleId));
    }

    List<org.w3c.dom.Node> rightNodeList = XMLUtil.getNodes(flowNode, "rights/right");
    for(org.w3c.dom.Node rightNode : rightNodeList){
      String username = XMLUtil.getSingleNodeTextContent(rightNode, "username");
      UUID roleId = daf.createUUID(XMLUtil.getSingleNodeTextContent(rightNode, "roleId"));
     
      UUID templateId = daf.createUUID(XMLUtil.getSingleNodeTextContent(rightNode, "templateId"));
      if (templateId == null) {
        continue;
      }
      this.rightSet.add(new Right(username, templateId, roleId));
    }
View Full Code Here

TOP

Related Classes of com.sogou.qadev.service.cynthia.factory.DataAccessFactory

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.