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

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


  @RequestMapping("/getUserReadableTemplate.do")
  public String getUserReadableTemplate(HttpServletRequest request , HttpSession httpSession) throws Exception {
    Key key   = ((Key)httpSession.getAttribute("key"));
    Long keyId = (Long)httpSession.getAttribute("kid");
    String templateTypeId = request.getParameter("templateTypeId");
    UUID templateTypeUUID = null;
    if (templateTypeId != null && !templateTypeId.equals("")) {
      templateTypeUUID = DataAccessFactory.getInstance().createUUID(templateTypeId);
    }
   
    das = DataAccessFactory.getInstance().createDataAccessSession(key.getUsername(), keyId);
View Full Code Here


      return dataMap;

    for (Field field : template.getFields()) {
      if (field.getType().equals(Type.t_selection)) {
        if (field.getDataType().equals(DataType.dt_single)) {
          UUID optionId = task.getSingleSelection(field.getId());
          if (optionId != null) {
            Option option = field.getOption(optionId);
            if (option != null)
              dataMap.put(field.getName(), option.getName());
          }
        } else {
          UUID[] optionIdArray = task
              .getMultiSelection(field.getId());
          if (optionIdArray != null && optionIdArray.length > 0) {
            StringBuffer valueStrb = new StringBuffer();
            for (UUID optionId : optionIdArray) {
              Option option = field.getOption(optionId);
              if (option != null) {
                if (valueStrb.length() > 0)
                  valueStrb.append(",");

                valueStrb.append("[").append(option.getName())
                    .append("]");
              }
            }

            if (valueStrb.length() > 0)
              dataMap.put(field.getName(), valueStrb.toString());
          }
        }
      } 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());
          }
View Full Code Here

   * @version:v1.0
   * @return
   */
  public TimerAction createTimerAction()
  {
    UUID timerActionId = DataAccessFactory.getInstance().newUUID("TIAC");
    return new TimerActionImpl(timerActionId);
  }
View Full Code Here

      pstm = conn.prepareStatement("SELECT * FROM timer_action");

      rst = pstm.executeQuery();
      while(rst.next())
      {
        UUID id = DataAccessFactory.getInstance().createUUID(rst.getObject("id").toString());
        TimerAction timerAction = new TimerActionImpl(id);

        timerAction.setName(rst.getString("name"));
        timerAction.setClassName(rst.getString("class_name"));
        timerAction.setMethod(rst.getString("method"));
View Full Code Here

      pstm.setString(1, userName);
     
      rst = pstm.executeQuery();
      while(rst.next())
      {
        UUID id = DataAccessFactory.getInstance().createUUID(rst.getObject("id").toString());
        TimerAction timerAction = new TimerActionImpl(id);

        timerAction.setName(rst.getString("name"));
        timerAction.setClassName(rst.getString("class_name"));
        timerAction.setMethod(rst.getString("method"));
View Full Code Here

   */
  @ResponseBody
  @RequestMapping("/initTemplateScripts.do")
  public String initTemplateScripts(@RequestParam("templateId") String templateIdStr) throws Exception {
   
    UUID templateId = DataAccessFactory.getInstance().createUUID(templateIdStr);
   
    Script[] templateScripts = das.queryTemplateScripts(templateId);
    Script[] allowedScripts  = das.queryAllowedTemplateScripts(templateId);
    Template template            = das.queryTemplate(templateId);
    Flow flow                  = das.queryFlow(template.getFlowId());
View Full Code Here

  @RequestMapping("/getFilterShowInfo.do")
  @ResponseBody
  public String getFilterShowInfo(HttpServletRequest request, HttpServletResponse response ,HttpSession session) throws Exception {
   
    String filterIdStr = request.getParameter("filterId");
    UUID filterId = DataAccessFactory.getInstance().createUUID(filterIdStr);
    DataAccessSession das = DataAccessFactory.getInstance().getSysDas();

    Filter filter = das.queryFilter(filterId);
   
    FilterField groupField = null;
    List<FilterField> showList = new ArrayList<FilterField>();
    List<FilterField> backList = new ArrayList<FilterField>();
    List<String> showFieldId = new ArrayList<String>();
   
    if(filter == null)
      return "";
   
    try {
      Document filterXmlDoc = XMLUtil.string2Document(filter.getXml(), "UTF-8");
     
      if (FilterQueryManager.isSysFilter(filter.getId().getValue())) {
        //系统过滤器
        List<Node> displayFieldNodes = XMLUtil.getNodes(filterXmlDoc, "query/templateType/display/field");
        showList.add(new FilterField("id", "编号"));
        showFieldId.add("id");
        for (Node node : displayFieldNodes) {
          if(XMLUtil.getAttribute(node,"id").equals("node_id"))
            continue;
          showFieldId.add(XMLUtil.getAttribute(node,"id"));
          showList.add(new FilterField(XMLUtil.getAttribute(node,"id"), XMLUtil.getAttribute(node,"name")));
        }
       
        groupField = new FilterField("node_id", "项目");
       
        for (String fieldId : baseFieldNameMap.keySet()) {
          if (!showFieldId.contains(fieldId)) {
            backList.add(new FilterField(fieldId, baseFieldNameMap.get(fieldId)));
          }
        }
      }else {
        Node templateNode = XMLUtil.getSingleNode(filterXmlDoc, "query/template");
        UUID templateId = DataAccessFactory.getInstance().createUUID(XMLUtil.getAttribute(templateNode,"id"));
       
        List<Node> displayFieldNodes = XMLUtil.getNodes(templateNode, "display/field");
        showList.add(new FilterField("id", "编号"));
        showFieldId.add("id");
        for (Node node : displayFieldNodes) {
          String fieldId = XMLUtil.getAttribute(node,"id");
          if(fieldId == null)
            continue;
          showFieldId.add(fieldId);
          if (CommonUtil.isPosNum(fieldId)) {
            //判断该字段目前存在
            if (FieldNameCache.getInstance().getFieldName(fieldId, templateId.getValue()) != null) {
              fieldId = "FIEL-" + fieldId;
            }else {
              continue;
            }
          }
         
          showList.add(new FilterField(fieldId, XMLUtil.getAttribute(node,"name")));
        }
       
        for (String fieldId : baseFieldNameMap.keySet()) {
          if (!showFieldId.contains(fieldId)) {
            backList.add(new FilterField(fieldId, baseFieldNameMap.get(fieldId)));
          }
        }
       
        Template template = das.queryTemplate(templateId);
       
        Set<Field> templateFields = template.getFields();
       
        for(Field field : templateFields)
        {
          if (!showFieldId.contains(field.getId().getValue())) {
            backList.add(new FilterField("FIEL-" + field.getId().getValue(), field.getName()));
          }
        }
       
        //分组字段
        Map<String, String> groupFieldMap = FilterAccessSession.getInstance().getGroupFieldMap(filter);
        if(groupFieldMap != null && groupFieldMap.keySet().size() > 0){
          for (String fieldId : groupFieldMap.keySet()) {
            String fieldName = groupFieldMap.get(fieldId);
            if(CommonUtil.isPosNum(fieldId)){
              if (FieldNameCache.getInstance().getFieldName(fieldId, templateId.getValue()) != null) {
                fieldId = "FIEL-" + fieldId;
              }else {
                continue;
              }
            }
View Full Code Here

   
    try {
      for (Field field : template.getFields()) {
        if (field.getType().equals(Type.t_selection) && field.getControlFieldId() != null) {
         
          UUID controlFieldId = field.getControlFieldId();
         
          UUID controlOptionId = data.getSingleSelection(controlFieldId);
         
          UUID curOptionId = data.getSingleSelection(field.getId());
         
          Option curOption = field.getOption(curOptionId);
         
          if (curOption == null || !curOption.getControlOptionId().getValue().equals(controlOptionId.getValue())) {
            Field controlField = template.getField(controlFieldId);
View Full Code Here

  private Set<Field> getMultField(Template template,UUID  actionId , Data data){
    if (data == null || actionId == null) {
      return null;
    }
   
    UUID roleId = DataAccessFactory.getInstance().createUUID("238784"); //筛选录入人员
   
    Set<Field> allMultFieldSet = new HashSet<Field>();
   
    allMultFieldSet.addAll(getMustFieldByAction(template, roleId, actionId));
   
View Full Code Here

    List<ErrorInfo> errorInfoList = new ArrayList<ErrorInfo>()//所有错误信息
    boolean flag = false; //添加过程是否出错
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Map<String, Integer> excelValueNum = new HashMap<String, Integer>()//excel表单【字段名,列数】对应

    UUID templateId = DataAccessFactory.getInstance().createUUID(templateIdStr);
    Template template = das.queryTemplate(templateId)//得到表单
    Flow flow = das.queryFlow(template.getFlowId());

    Set<Field> allFields = GetAllFields(template);//表单所有字段,除出废弃字段

    String addUser = (String)session.getAttribute("userName");
    DataAccessSession das = DataAccessFactory.getInstance().createDataAccessSession(addUser, DataAccessFactory.magic);
    Set<Field> allNeedFields = new HashSet<Field>();
    //////////////////////////////////////////

    try
    {
      File tmpFile = File.createTempFile("acctachment", ".attachment");
      multipartFile.transferTo(tmpFile);
      String realFileName = multipartFile.getOriginalFilename();
      FileInputStream fis = new FileInputStream(tmpFile);
     
      Workbook workbook = WorkbookFactory.create(fis);
     
      if (fis != null) {
        StreamCloserManager.closeInputStream(fis);
      }
      if (workbook == null) {
        return "";
      }

      try{
        Sheet sheet = workbook.getSheet(sheetName);
        int rows = sheet.getPhysicalNumberOfRows();
        Row row = null;
        Cell cell = null;
        if(rows==0)
          return "";
        row = sheet.getRow(0);//获得第一行数据分析每个字段对应的列号

        String value = null;
        int cells = row.getPhysicalNumberOfCells();
        for(int j=0;j<cells;j++){
          cell = row.getCell(j);
          value = cell.getStringCellValue().trim();
          if (value!=null && value.length()>0) {
            excelValueNum.put(value, j);
          }
        }

        if (rows==1) {
          ErrorInfo errorInfo = new ErrorInfo();
          errorInfo.setErrorDescription("数据为空");
          errorInfoList.add(errorInfo);
          flag = false;
        }
       
        Boolean isAllNeedFieldsIn = true//必须字段是否全部满足
        //判断必填字段是否都己存在
        String needFieldName = GetNeedFieldString(excelValueNum, template);

        if (needFieldName!=null && needFieldName.length()>0) {
          ErrorInfo errorInfo = new ErrorInfo();
          errorInfo.setErrorDescription("某些字段在表单中无法找到如:【"+needFieldName+"】,全部录入失败");
          errorInfoList.add(errorInfo);
          flag = false;
          isAllNeedFieldsIn = false;
        }
       
        if (isAllNeedFieldsIn) {
          for(int j=1;j<rows;j++)
          {

            row = sheet.getRow(j);
            if(row!=null)
            {
              boolean isSingleFail = false//单条信息录入错误

              Map<String, Pair<Object, Object>> baseValueMap = new LinkedHashMap<String, Pair<Object, Object>>();
              Map<UUID, Pair<Object, Object>> extValueMap = new LinkedHashMap<UUID, Pair<Object, Object>>();
              Data data = das.addData(templateId);

              String title = "";       //标题
              ErrorInfo errorInfo = null;

              if(data == null){
                return "";
              }

              for (Field field : allFields) {
                if (excelValueNum.keySet().contains(field.getName())) {
                  String fieldName = field.getName();
                  //excel中存在该字段,从excel中获取内容
                  String cellContentString = "";
                  java.util.Date cellContentDate = null;
                  if(row.getCell(excelValueNum.get(fieldName))!=null)
                  {
                    if(row.getCell(excelValueNum.get(fieldName)).getCellType()==XSSFCell.CELL_TYPE_NUMERIC//日期类型
                    {
                      cellContentDate = row.getCell(excelValueNum.get(fieldName)).getDateCellValue();
                      cellContentString = CynthiaUtil.getValue(row, excelValueNum.get(fieldName));
                    }else{
                      //其它类型
                      cellContentString = CynthiaUtil.getValue(row, excelValueNum.get(fieldName));
                    }

                  }else {
                    //判断该字段是否为必填
                    if (allNeedFields.contains(field.getName())) {
                      //必填为空,错误
                      isSingleFail = true;
                      errorInfo = new ErrorInfo() ;
                      errorInfo.setErrorDescription("必填字段为空");
                      errorInfo.setErrorRowNum(j);
                      errorInfo.setErrorColumnName(field.getName());
                      break;
                    }
                  }

                  if (field.getDataType()==DataType.dt_timestamp) { //处理日期类型
                    Date timeDate = null;
                    try {
                      timeDate = Date.valueOf(sdf.format(cellContentDate));
                     
                    } catch (Exception e) {
                    }
                    if (timeDate == null) {
                      try {
                        timeDate = Date.valueOf(cellContentString);
                      } catch (Exception e) {
                      }
                    }
                    if (timeDate == null && allNeedFields.contains(fieldName)) {
                      // 日期类型错误 返回错误
                      isSingleFail = true;
                      errorInfo = new ErrorInfo() ;
                      errorInfo.setErrorDescription("日期类型错误");
                      errorInfo.setErrorRowNum(j);
                      errorInfo.setErrorColumnName(field.getName());
                      break;
                    }else {
                      if (timeDate != null) {
                        data.setDate(field.getId(), timeDate);
                        extValueMap.put(field.getId(), new Pair<Object, Object>(null, timeDate));
                      }
                    }
                  }else if (field.getType()==Type.t_selection) {  //处理单选类型
                    Option option = field.getOption(cellContentString);
                    if (option == null) {
                      if (allNeedFields.contains(field)) {  //为空必填
                        //错误,单选选项错误
                        isSingleFail = true;
                        errorInfo = new ErrorInfo() ;
                        errorInfo.setErrorDescription("单选选项错误");
                        errorInfo.setErrorRowNum(j);
                        errorInfo.setErrorColumnName(field.getName());
                        break;
                      }
                    }else {
                      data.setSingleSelection(field.getId(), option.getId());
                      extValueMap.put(field.getId(), new Pair<Object, Object>(null,option.getId()));
                    }
                  }else //普通字段类型
                    data.setString(field.getId(), cellContentString);
                    extValueMap.put(field.getId(), new Pair<Object, Object>(null, cellContentString));
                  }
                }

              }//end foreach

              if (isSingleFail) {
                //记录错误 开始下一条数据录入
                failCount ++;
                errorInfoList.add(errorInfo);
                continue;
              }
             
              //问题概述
              if (excelValueNum.get("标题")!=null) {
                title = CynthiaUtil.getValue(row, excelValueNum.get("标题"));
              }
             
              //标题
              data.setTitle(title);
              baseValueMap.put("title", new Pair<Object, Object>(null,title));

              data.setObject("logCreateUser", addUser)//添加人
              //正文
              if (excelValueNum.get("正文")!=null) {
                String content = CynthiaUtil.getValue(row, excelValueNum.get("正文"));
                data.setDescription(content);
                baseValueMap.put("description", new Pair<Object, Object>(null, content));
              }
             
              //状态
              UUID statId = null;
              if (excelValueNum.get("状态")!=null) {
                String statIdStr = CynthiaUtil.getValue(row, excelValueNum.get("状态"));
                if (statIdStr != null && statIdStr.length() >0) {
                  Stat stat = flow.getStat(statIdStr);
                  if (stat == null) {
View Full Code Here

TOP

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

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.