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

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


        hasPriority = true;

      element = document.createElement("field");
      element.setAttribute("name", fieldName);

      Field field = template.getField(fieldName);
      String fieldId = (field == null ? ConfigUtil.baseFieldIdMap
          .get(fieldName) : field.getId().toString());

      element.setAttribute("uuid", fieldId);

      String value = getTaskBaseAttribute(task, fieldName, das);
View Full Code Here


   * @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();
    }
View Full Code Here

        {
          List<Node> fieldNodes = XMLUtil.getNodes(columnNode, "field");
          FieldColumn fieldColumn = new FieldColumn();
          for(Node fieldNode : fieldNodes)
          {
            Field tempField = initFieldNode(fieldNode);
            fieldColumn.addField(tempField);
            this.fieldSet.add(tempField);
          }
          fieldRow.addColumn(fieldColumn);
        }
View Full Code Here

      for(FieldColumn fieldColumn : fieldRow.getFieldColumns())
      {
        FieldColumn newFieldColumn = new FieldColumn();
        for(Field field : fieldColumn.getFields())
        {
          Field newField = field.clone();
          newFieldColumn.addField(newField);
          templateImpl.fieldSet.add(newField);
        }
        newFieldRow.addColumn(newFieldColumn);
      }
View Full Code Here

   * @see com.sogou.qadev.service.cynthia.bean.Template#addField(com.sogou.qadev.service.cynthia.bean.Field.Type, com.sogou.qadev.service.cynthia.bean.Field.DataType)
   */
  public Field addField(Type type, DataType dataType)
  {
    UUID fieldId = DataAccessFactory.getInstance().newUUID("FIEL");
    Field field = new FieldImpl(fieldId, this.id, type, dataType);
    this.fieldSet.add(field);
    return field;
  }
View Full Code Here

      {
        List<Field> fields = fieldColumns.get(j).getFields();
        Iterator<Field> fieldsItr = fields.iterator();
        while(fieldsItr.hasNext())
        {
          Field tmpField = fieldsItr.next();
          if(tmpField.getId().equals(field.getId()))
          {
            fieldsItr.remove();
            this.addField(field, rowIndex, columnIndex, positionIndex);
            return true;
          }
View Full Code Here

  public void removeField(UUID fieldId , UUID templateId)
  {
    Iterator<Field> fieldSetItr = this.fieldSet.iterator();
    while (fieldSetItr.hasNext())
    {
      Field field = fieldSetItr.next();
      if (field.getId().equals(fieldId))
        fieldSetItr.remove();
    }

    for(int i = 0; i < fieldRowList.size() ; i++)
    {
      List<FieldColumn> fieldColumns = fieldRowList.get(i).getFieldColumns();
      for(int j = 0 ; j < fieldColumns.size() ; j++)
      {
        List<Field> fields = fieldColumns.get(j).getFields();
        Iterator<Field> fieldsItr = fields.iterator();
        while(fieldsItr.hasNext())
        {
          Field tmpField = fieldsItr.next();
          if(tmpField.getId().equals(fieldId))
            fieldsItr.remove();
        }
      }
    }
View Full Code Here

    Template template = dataAccessSession.queryTemplate(templateId);
    if(template == null){
      return new Data[0];
    }
   
    Field field = template.getField(fieldId);
    if(field == null || !field.getType().equals(Type.t_reference)){
      return new Data[0];
    }
   
    List<String> queryFieldsList = new ArrayList<String>();
    queryFieldsList.add("id");
    queryFieldsList.add("title");
    queryFieldsList.add("templateId");
    Map<String, String> whereMap = new HashMap<String, String>();
   
    Map<UUID, Data> refDataMap = new LinkedHashMap<UUID, Data>();
   
    String fieldColName = FieldNameCache.getInstance().getFieldName(fieldId ,templateId);
   
    String[] allRefValue = new DataAccessSessionMySQL().queryFieldByTemplate(templateId, fieldColName);
   
    for(String refValue : allRefValue){
      if (refValue == null || refValue.length() ==0) {
        continue;
      }
     
      if(field.getDataType().equals(DataType.dt_single)){
        whereMap.put("id", refValue);
        List<Data> refData = new DataAccessSessionMySQL().queryDatas(TableRuleManager.getInstance().getAllDataTables(), queryFieldsList, whereMap, null, null,false,templateId);
       
        if(refData != null && refData.size() > 0){
          refDataMap.put(DataAccessFactory.getInstance().createUUID(refValue), refData.get(0));
View Full Code Here

    Template template = TemplateCache.getInstance().get(templateId);
    if(template == null){
      return new Attachment[0];
    }
   
    Field field = template.getField(fieldId);
    if(field == null || !field.getType().equals(Type.t_attachment)){
      return new Attachment[0];
    }
   
    String fieldColName = FieldNameCache.getInstance().getFieldName(fieldId , templateId);
   
View Full Code Here

   */
  public Field queryField(UUID fieldId)
  {
    List<Template> allTemplates = getAll();
    for (Template template : allTemplates) {
      Field field = template.getField(fieldId);
      if(field != null)
        return field;
    }

    return null;
View Full Code Here

TOP

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

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.