示例#1
0
 private Map<String, Map> generateResultMapForBibTreeWithItemUuidAndResultType(BibTrees bibTrees) {
   Map<String, Map> resultTypeMap = new HashMap<>();
   if (null != bibTrees) {
     List<BibTree> bibTreeList = bibTrees.getBibTrees();
     if (CollectionUtils.isNotEmpty(bibTreeList)) {
       for (Iterator<BibTree> bibTreeIterator = bibTreeList.iterator();
           bibTreeIterator.hasNext(); ) {
         BibTree bibTree = bibTreeIterator.next();
         List<HoldingsTree> holdingsTrees = bibTree.getHoldingsTrees();
         if (CollectionUtils.isNotEmpty(holdingsTrees)) {
           for (Iterator<HoldingsTree> holdingsTreeIterator = holdingsTrees.iterator();
               holdingsTreeIterator.hasNext(); ) {
             HoldingsTree holdingsTree = holdingsTreeIterator.next();
             List<Item> items = holdingsTree.getItems();
             if (CollectionUtils.isNotEmpty(items)) {
               for (Iterator<Item> itemIterator = items.iterator(); itemIterator.hasNext(); ) {
                 Item item = itemIterator.next();
                 Map statusMap = new HashMap();
                 statusMap.put("result", item.getResult());
                 statusMap.put("message", item.getMessage());
                 statusMap.put("barcode", item.getBarcode());
                 resultTypeMap.put(item.getId(), statusMap);
               }
             }
           }
         }
       }
     }
   }
   return resultTypeMap;
 }
  @Override
  public void doProcess(
      PublishedChangeSet changeSet, Map<String, String> parameters, PublishingTarget target)
      throws PublishingException {
    String root = target.getParameter(FileUploadServlet.CONFIG_ROOT);
    String contentFolder = target.getParameter(FileUploadServlet.CONFIG_CONTENT_FOLDER);
    String siteId =
        (!StringUtils.isEmpty(siteName)) ? siteName : parameters.get(FileUploadServlet.PARAM_SITE);

    root += "/" + contentFolder;

    if (StringUtils.isNotBlank(siteId)) {
      root = root.replaceAll(FileUploadServlet.CONFIG_MULTI_TENANCY_VARIABLE, siteId);
    }

    List<String> createdFiles = changeSet.getCreatedFiles();
    List<String> updatedFiles = changeSet.getUpdatedFiles();
    List<String> deletedFiles = changeSet.getDeletedFiles();

    if (CollectionUtils.isNotEmpty(createdFiles)) {
      update(siteId, root, createdFiles, false);
    }
    if (CollectionUtils.isNotEmpty(updatedFiles)) {
      update(siteId, root, updatedFiles, false);
    }
    if (CollectionUtils.isNotEmpty(deletedFiles)) {
      update(siteId, root, deletedFiles, true);
    }

    searchService.commit();
  }
  private void compareTableMetaData() {

    if (this.srcTableMetaData == null) {
      throw new RuntimeException("src table meta is null");
    }

    if (this.tgtTableMetaData == null) {
      throw new RuntimeException("tgt table meta is null");
    }
    List<ColumnMetaData> srcColumnMetaDatas = srcTableMetaData.getColumnMetaDatas();
    List<ColumnMetaData> tgtColumnMetaDatas = tgtTableMetaData.getColumnMetaDatas();

    Iterator<ColumnMetaData> metaDataIterator = srcColumnMetaDatas.iterator();
    while (metaDataIterator.hasNext()) {
      ColumnMetaData rowData = metaDataIterator.next();
      int index = tgtColumnMetaDatas.indexOf(rowData);
      if (index > -1) {
        metaDataIterator.remove();
        tgtColumnMetaDatas.remove(index);
      }
    }

    if (CollectionUtils.isNotEmpty(srcColumnMetaDatas)
        || CollectionUtils.isNotEmpty(tgtColumnMetaDatas)) {
      String errorInfo =
          String.format(
              "src table meta [%s] not equal tgt meta [%s]",
              joiner.join(srcColumnMetaDatas), joiner.join(tgtColumnMetaDatas));
      throw new RuntimeException(errorInfo);
    }
  }
  private List<Long> mergeIds(
      List<Long> pgcList,
      List<DcPromotionAwardDTO> hisAwardList,
      List<DcPromotionItemDTO>... allPromotionItemList) {
    List<Long> mergeIdList = new ArrayList<Long>();

    if (CollectionUtils.isNotEmpty(pgcList)) {
      mergeIdList.addAll(pgcList);
    }

    for (List<DcPromotionItemDTO> promotionItemList : allPromotionItemList) {
      if (CollectionUtils.isNotEmpty(promotionItemList)) {
        for (DcPromotionItemDTO pi : promotionItemList) {
          mergeIdList.add(pi.getItemId());
        }
      }
    }

    if (CollectionUtils.isNotEmpty(hisAwardList)) {
      for (DcPromotionAwardDTO pa : hisAwardList) {
        mergeIdList.add(pa.getItemId());
      }
    }

    return mergeIdList;
  }
示例#5
0
 @Override
 public boolean isDataForSignatureLevelPresent(SignatureLevel signatureLevel) {
   boolean dataForLevelPresent = true;
   switch (signatureLevel) {
     case PAdES_BASELINE_LTA:
       dataForLevelPresent = CollectionUtils.isNotEmpty(getArchiveTimestamps());
       // c &= fct() will process fct() all time ; c = c && fct() will process fct() only if c is
       // true
       dataForLevelPresent =
           dataForLevelPresent && isDataForSignatureLevelPresent(SignatureLevel.PAdES_BASELINE_LT);
       break;
     case PAdES_BASELINE_LT:
       dataForLevelPresent = hasDSSDictionary();
       dataForLevelPresent =
           dataForLevelPresent && isDataForSignatureLevelPresent(SignatureLevel.PAdES_BASELINE_T);
       break;
     case PAdES_BASELINE_T:
       dataForLevelPresent = CollectionUtils.isNotEmpty(getSignatureTimestamps());
       dataForLevelPresent =
           dataForLevelPresent && isDataForSignatureLevelPresent(SignatureLevel.PAdES_BASELINE_B);
       break;
     case PAdES_BASELINE_B:
       dataForLevelPresent = (pdfSignatureInfo != null);
       break;
     default:
       throw new IllegalArgumentException("Unknown level " + signatureLevel);
   }
   logger.debug(
       "Level {} found on document {} = {}",
       new Object[] {signatureLevel, document.getName(), dataForLevelPresent});
   return dataForLevelPresent;
 }
  private SearchResponse doSearch(SearchRequestBuilder searchRequest, SearchQuery searchQuery) {
    if (searchQuery.getFilter() != null) {
      searchRequest.setPostFilter(searchQuery.getFilter());
    }

    if (CollectionUtils.isNotEmpty(searchQuery.getElasticsearchSorts())) {
      for (SortBuilder sort : searchQuery.getElasticsearchSorts()) {
        searchRequest.addSort(sort);
      }
    }

    if (CollectionUtils.isNotEmpty(searchQuery.getFacets())) {
      for (FacetRequest facetRequest : searchQuery.getFacets()) {
        FacetBuilder facet = facetRequest.getFacet();
        if (facetRequest.applyQueryFilter() && searchQuery.getFilter() != null) {
          facet.facetFilter(searchQuery.getFilter());
        }
        searchRequest.addFacet(facet);
      }
    }

    if (searchQuery.getHighlightFields() != null) {
      for (HighlightBuilder.Field highlightField : searchQuery.getHighlightFields()) {
        searchRequest.addHighlightedField(highlightField);
      }
    }

    if (CollectionUtils.isNotEmpty(searchQuery.getAggregations())) {
      for (AbstractAggregationBuilder aggregationBuilder : searchQuery.getAggregations()) {
        searchRequest.addAggregation(aggregationBuilder);
      }
    }

    return searchRequest.setQuery(searchQuery.getQuery()).execute().actionGet();
  }
 @Override
 public void postUpdate(
     ApplicationInfo appInfo,
     List<ArtifactGroup> artifactGroups,
     List<ArtifactGroup> deletedFeatures)
     throws PhrescoException {
   File pomFile =
       new File(
           Utility.getProjectHome()
               + appInfo.getAppDirName()
               + File.separator
               + Constants.POM_NAME);
   ProjectUtils projectUtils = new ProjectUtils();
   projectUtils.deletePluginExecutionFromPom(pomFile);
   if (CollectionUtils.isNotEmpty(deletedFeatures)) {
     projectUtils.removeExtractedFeatures(appInfo, deletedFeatures);
   }
   if (CollectionUtils.isNotEmpty(artifactGroups)) {
     projectUtils.updatePOMWithPluginArtifact(pomFile, artifactGroups);
     excludeModule(appInfo, artifactGroups);
   }
   BufferedReader breader = projectUtils.ExtractFeature(appInfo);
   try {
     String line = "";
     while ((line = breader.readLine()) != null) {
       if (line.startsWith("[ERROR]")) {
         System.err.println(line);
       }
     }
   } catch (IOException e) {
     throw new PhrescoException(e);
   }
 }
示例#8
0
  /**
   * 查询当天的监控数据
   *
   * @param handlerName 例smsGeneralHandler
   * @param monitorTime 例201509/02
   * @return
   */
  public static Map<String, List<MonitorRecord>> queryMonitorData(
      String handlerName, Date monitorTime) {

    Map<String, List<MonitorRecord>> result = null;

    // 加载文件列表
    List<File> monitorFiles = queryFiles(handlerName, monitorTime);

    if (CollectionUtils.isNotEmpty(monitorFiles)) {
      result = new HashMap<String, List<MonitorRecord>>();
      for (File fileItem : monitorFiles) {

        String hostName =
            fileItem.getName().substring(handlerName.length() + 1, fileItem.getName().length() - 4);
        // 解析文件
        List<MonitorRecord> list = parseFileItem(fileItem);

        if (CollectionUtils.isNotEmpty(list)) {
          Collections.sort(list);
          result.put(hostName, list);
        }
      }
    }
    return result;
  }
示例#9
0
  public List<ProductCategoryDTO> getProductCategoryByNameOrId(
      Long productCategoryId, String name, Long shopId, Pager pager) {
    ProductWriter productWriter = productDaoManager.getWriter();
    List<ProductCategory> productCategoryList = null;

    if (productCategoryId == null && StringUtil.isEmpty(name)) {
      productCategoryList = productWriter.getProductCategoryFuzzyName(shopId, null, pager);
      List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
      if (CollectionUtils.isNotEmpty(productCategoryList)) {
        for (ProductCategory productCategory : productCategoryList) {
          productCategoryDTOList.add(productCategory.toDTO());
        }
      }
      return productCategoryDTOList;
    }

    if (StringUtil.isNotEmpty(name)) {
      productCategoryList = productWriter.getProductCategoryFuzzyName(shopId, name, pager);
      List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
      if (CollectionUtils.isNotEmpty(productCategoryList)) {
        for (ProductCategory productCategory : productCategoryList) {
          productCategoryDTOList.add(productCategory.toDTO());
        }
      }
      return productCategoryDTOList;
    }

    if (productCategoryId != null) {
      List<ProductCategoryDTO> productCategoryDTOList =
          this.getProductCategoryDTOByParentId(shopId, productCategoryId, pager);
      return productCategoryDTOList;
    }

    return null;
  }
 /**
  * Used for bind and update.
  *
  * @param person
  * @return
  * @see org.projectforge.ldap.LdapDao#getModificationItems(org.projectforge.ldap.LdapObject)
  */
 @Override
 protected List<ModificationItem> getModificationItems(
     final List<ModificationItem> list, final LdapGroup group) {
   createAndAddModificationItems(list, "businessCategory", group.getBusinessCategory());
   createAndAddModificationItems(list, "o", group.getOrganization());
   createAndAddModificationItems(list, "description", group.getDescription());
   if (CollectionUtils.isNotEmpty(group.getMembers()) == true) {
     createAndAddModificationItems(list, "uniqueMember", group.getMembers());
   } else {
     createAndAddModificationItems(list, "uniqueMember", NONE_UNIQUE_MEMBER_ID);
   }
   final boolean modifyPosixAccount =
       isPosixAccountsConfigured() == true
           && GroupDOConverter.isPosixAccountValuesEmpty(group) == false;
   if (modifyPosixAccount == true) {
     if (group.getObjectClasses() != null) {
       final List<String> missedObjectClasses =
           LdapUtils.getMissedObjectClasses(
               getAdditionalObjectClasses(group), getObjectClass(), group.getObjectClasses());
       if (CollectionUtils.isNotEmpty(missedObjectClasses) == true) {
         for (final String missedObjectClass : missedObjectClasses) {
           list.add(
               createModificationItem(DirContext.ADD_ATTRIBUTE, "objectClass", missedObjectClass));
         }
       }
     }
   }
   if (modifyPosixAccount == true) {
     createAndAddModificationItems(list, "gidNumber", String.valueOf(group.getGidNumber()));
   }
   return list;
 }
示例#11
0
 /**
  * 递归查询用户菜单
  *
  * @param pid
  * @param userId
  * @return
  */
 private List<Map<String, Object>> recursive(String pid, String userId) {
   List<Map<String, Object>> resList = Lists.newArrayList();
   List<Map<String, Object>> list;
   StringBuilder sql = new StringBuilder(100);
   sql.append("select ").append(getColumnsStr("a"));
   sql.append(" from ").append(getTableName()).append(" a ");
   if (StringUtils.isNotBlank(userId)) {
     sql.append(" join ")
         .append(getTableName(SysRoleMenu.class))
         .append(" c ON a.id = c.menu_id ");
     sql.append(" join ").append(getTableName(SysRole.class)).append(" b ON c.role_id = b.id ");
     sql.append(" join ")
         .append(getTableName(SysUserRole.class))
         .append(" d ON b.id = d.role_id ");
     sql.append(" join ").append(getTableName(SysUser.class)).append(" e ON d.user_id = e.id ");
   }
   sql.append(" where 1 = 1 ");
   List<Object> params = Lists.newArrayList();
   if (StringUtils.isNotBlank(userId)) {
     sql.append("and e.id = ? and b.is_valid = '1' and a.is_valid = '1' and e.is_valid = '1' ");
     params.add(userId);
   }
   if (StringUtils.isBlank(pid)) {
     sql.append(" and (a.parent_id is null or a.parent_id = '') ").append(ORDER_BY);
   } else {
     sql.append(" and a.parent_id = ? ").append(ORDER_BY);
     params.add(pid);
   }
   list = findList(sql.toString(), params.toArray());
   if (CollectionUtils.isNotEmpty(list)) {
     for (Map<String, Object> m : list) {
       String _id = m.get("id") + "";
       // 如果存在子节点(不是叶子节点),则继续递归查询
       resList.add(m);
       // 是否还有要显示的子菜单
       boolean isShowNext = false;
       if (!isLeef(_id)) {
         List<Map<String, Object>> tmpList = recursive(_id, userId);
         m.put("isLeef", false);
         m.put("isParent", true);
         if (CollectionUtils.isNotEmpty(tmpList)) {
           for (Map<String, Object> tm : tmpList) {
             if (AppConfig.YES.equals(tm.get("is_show")) && _id.equals(tm.get("parent_id"))) {
               isShowNext = true;
               break;
             }
           }
         }
         resList.addAll(tmpList);
       } else {
         m.put("isLeef", true);
         m.put("isParent", false);
       }
       m.put("isShowNext", isShowNext);
     }
   }
   return resList;
 }
示例#12
0
  private void handleFindMutationsByTerm(Tuple request) {
    //		if (StringUtils.isNotEmpty(request.getString("term")) && request.getString("term").length()
    // < 3)
    //		throw new SearchException("Search term is too general. Please use a more specific one.");

    if (StringUtils.isNotEmpty(request.getString("result")))
      this.getModel().setResult(request.getString("result"));
    else this.getModel().setResult("mutations"); // Default: Show mutations

    this.getModel().setMutationSummaryVOHash(new HashMap<String, String>());
    this.getModel().setPatientSummaryVOHash(new HashMap<String, String>());

    SearchService searchService = ServiceLocator.instance().getSearchService();

    if (this.getModel().getResult().equals("patients")) {
      HashMap<String, List<PatientSummaryDTO>> result =
          searchService.findPatientsByTerm(request.getString("term"));

      int numPatients = 0;

      for (String key : result.keySet()) {
        if (CollectionUtils.isNotEmpty(result.get(key))) {
          ((HttpServletRequestTuple) request)
              .getRequest()
              .setAttribute("patientSummaryVOs", result.get(key));
          this.getModel()
              .getPatientSummaryVOHash()
              .put(" " + key + " ", this.include(request, this.getModel().getPatientPager()));
          numPatients += result.get(key).size();
        }
      }

      this.getModel().setHeader(numPatients + " patients found.");
    } else if (this.getModel().getResult().equals("mutations")) {
      HashMap<String, List<MutationSummaryDTO>> result =
          searchService.findMutationsByTerm(request.getString("term"));

      int numMutations = 0;

      for (String key : result.keySet()) {
        if (CollectionUtils.isNotEmpty(result.get(key))) {
          ((HttpServletRequestTuple) request)
              .getRequest()
              .setAttribute("mutationSummaryDTOList", result.get(key));
          this.getModel()
              .getMutationSummaryVOHash()
              .put(" " + key + " ", this.include(request, this.getModel().getMutationPager()));
          numMutations += result.get(key).size();
        }
      }

      this.getModel().setHeader(numMutations + " mutations found.");
    }

    this.setView(new FreemarkerView("freetext.ftl", this.getModel()));
  }
示例#13
0
 @Override
 public void setUp() throws Exception {
   super.setUp();
   List<DownloadablePackage> local = getDownloads("localhf2.json");
   List<DownloadablePackage> remote = getDownloads("remotehf2.json");
   assertTrue(CollectionUtils.isNotEmpty(local));
   assertTrue(CollectionUtils.isNotEmpty(remote));
   pm.registerSource(new DummyPackageSource(local, "localhf2"), true);
   pm.registerSource(new DummyPackageSource(remote, "remotehf2"), false);
 }
  public static void updateVertexPreUpdate(
      AtlasStructDef structDef,
      AtlasStructType structType,
      AtlasVertex vertex,
      AtlasTypeDefGraphStoreV1 typeDefStore)
      throws AtlasBaseException {

    List<String> attrNames = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(structDef.getAttributeDefs())) {
      for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) {
        attrNames.add(attributeDef.getName());
      }
    }

    List<String> currAttrNames =
        vertex.getProperty(AtlasGraphUtilsV1.getPropertyKey(structDef), List.class);

    // delete attributes that are not present in updated structDef
    if (CollectionUtils.isNotEmpty(currAttrNames)) {
      for (String currAttrName : currAttrNames) {
        if (!attrNames.contains(currAttrName)) {
          throw new AtlasBaseException(
              AtlasErrorCode.ATTRIBUTE_DELETION_NOT_SUPPORTED, structDef.getName(), currAttrName);
        }
      }
    }

    typeDefStore.updateTypeVertex(structDef, vertex);

    // add/update attributes that are present in updated structDef
    if (CollectionUtils.isNotEmpty(structDef.getAttributeDefs())) {
      for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) {
        if (CollectionUtils.isEmpty(currAttrNames)
            || !currAttrNames.contains(attributeDef.getName())) {
          // new attribute - only allow if optional
          if (!attributeDef.isOptional()) {
            throw new AtlasBaseException(
                AtlasErrorCode.CANNOT_ADD_MANDATORY_ATTRIBUTE,
                structDef.getName(),
                attributeDef.getName());
          }
        }

        String propertyKey = AtlasGraphUtilsV1.getPropertyKey(structDef, attributeDef.getName());

        AtlasGraphUtilsV1.setProperty(
            vertex, propertyKey, toJsonFromAttributeDef(attributeDef, structType));
      }
    }

    AtlasGraphUtilsV1.setProperty(vertex, AtlasGraphUtilsV1.getPropertyKey(structDef), attrNames);
  }
 @Override
 public List<String> getUsersByAuthorities(List<String> groupNames, List<String> roleNames) {
   FieldSearchFilter[] filters = {};
   if (CollectionUtils.isNotEmpty(groupNames)) {
     FieldSearchFilter filter = new FieldSearchFilter("groupname", groupNames, false);
     filters = super.addFilter(filters, filter);
   }
   if (CollectionUtils.isNotEmpty(roleNames)) {
     FieldSearchFilter filter = new FieldSearchFilter("rolename", roleNames, false);
     filters = super.addFilter(filters, filter);
   }
   return super.searchId(filters);
 }
示例#16
0
  @Test
  public void getMovieLinks() {
    Movie movie = _movieService.getMovieById(3873); // The Revenant
    assertNotNull(movie);
    Set<MovieLink> movieLinks = movie.getMovieLinks();
    assertTrue(CollectionUtils.isNotEmpty(movieLinks));
    assertEquals(1, movieLinks.size());

    movie = _movieService.getMovieById(3916); // The Man in the Wilderness
    assertNotNull(movie);
    movieLinks = movie.getMovieLinks();
    assertTrue(CollectionUtils.isNotEmpty(movieLinks));
    assertEquals(1, movieLinks.size());
  }
 @Override
 public List<String> getEPersonDeleteConstraints(Context context, EPerson ePerson)
     throws SQLException {
   List<String> resultList = new ArrayList<>();
   List<BasicWorkflowItem> workflowItems = workflowItemService.findByOwner(context, ePerson);
   if (CollectionUtils.isNotEmpty(workflowItems)) {
     resultList.add("workflowitem");
   }
   List<TaskListItem> taskListItems = taskListItemService.findByEPerson(context, ePerson);
   if (CollectionUtils.isNotEmpty(taskListItems)) {
     resultList.add("tasklistitem");
   }
   return resultList;
 }
示例#18
0
 @Override
 public List<String> getEPersonDeleteConstraints(Context context, EPerson ePerson)
     throws SQLException {
   List<String> constraints = new ArrayList<String>();
   if (CollectionUtils.isNotEmpty(claimedTaskService.findByEperson(context, ePerson))) {
     constraints.add("cwf_claimtask");
   }
   if (CollectionUtils.isNotEmpty(poolTaskService.findByEPerson(context, ePerson))) {
     constraints.add("cwf_pooltask");
   }
   if (CollectionUtils.isNotEmpty(workflowItemRoleService.findByEPerson(context, ePerson))) {
     constraints.add("cwf_workflowitemrole");
   }
   return constraints;
 }
示例#19
0
  public String createReportConfig() {
    S_LOGGER.debug("Entering Method  SiteReport.createReportConfig()");

    try {
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      ProjectInfo projectInfo = administrator.getProject(projectCode).getProjectInfo();

      // To get the selected reports from the UI
      String[] arraySelectedReports = getHttpRequest().getParameterValues(REQ_SITE_REPORTS);
      List<String> selectedReports = null;
      if (!ArrayUtils.isEmpty(arraySelectedReports)) {
        selectedReports = Arrays.asList(arraySelectedReports);
      }

      // To get the selected ReportCategories from the UI
      String[] arraySelectedRptCategories =
          getHttpRequest().getParameterValues(REQ_SITE_SLECTD_REPORTSCATEGORIES);
      List<ReportCategories> selectedReportCategories = new ArrayList<ReportCategories>();
      if (!ArrayUtils.isEmpty(arraySelectedRptCategories)) {
        for (String arraySelectedRptCategory : arraySelectedRptCategories) {
          ReportCategories cat = new ReportCategories();
          cat.setName(arraySelectedRptCategory);
          selectedReportCategories.add(cat);
        }
      }

      // To get the list of Reports to be added
      List<Reports> allReports = administrator.getReports(projectInfo);
      List<Reports> reportsToBeAdded = new ArrayList<Reports>();
      if (CollectionUtils.isNotEmpty(selectedReports) && CollectionUtils.isNotEmpty(allReports)) {
        for (Reports report : allReports) {
          if (selectedReports.contains(report.getArtifactId())) {
            reportsToBeAdded.add(report);
          }
        }
      }

      administrator.updateRptPluginInPOM(projectInfo, reportsToBeAdded, selectedReportCategories);
      addActionMessage(getText(SUCCESS_SITE_CONFIGURE));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of SiteReport.createReportConfig()"
              + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "Configuring site report");
    }

    return viewSiteReport();
  }
  @Override
  public ShoppingCart populateAddressAndShippingFields(
      final ShoppingCart shoppingCart, final CartOrder cartOrder) {
    Address billingAddress = getBillingAddress(cartOrder);
    shoppingCart.setBillingAddress(billingAddress);
    Address shippingAddress = getShippingAddress(cartOrder);
    shoppingCart.setShippingAddress(shippingAddress);
    Store store = shoppingCart.getStore();
    List<ShippingServiceLevel> shippingServiceLevels =
        shippingServiceLevelService.retrieveShippingServiceLevel(store.getCode(), shippingAddress);

    if (CollectionUtils.isNotEmpty(shippingServiceLevels)) {

      String shippingServiceLevelGuidFromCartOrder = cartOrder.getShippingServiceLevelGuid();
      ShippingServiceLevel matchingShippingServiceLevel =
          getShippingServiceLevelMatchingGuid(
              shippingServiceLevels, shippingServiceLevelGuidFromCartOrder);

      if (matchingShippingServiceLevel != null) {
        shoppingCart.setShippingServiceLevelList(shippingServiceLevels);
        shoppingCart.setSelectedShippingServiceLevelUid(matchingShippingServiceLevel.getUidPk());
      }
    }

    return shoppingCart;
  }
 /**
  * 统计注册人数
  *
  * @creationDate. 2015-12-25 下午4:22:25
  * @throws ParseException
  */
 public void statistics() throws ParseException {
   List<YwUser> data = getData();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd");
   JSONObject jsonData = new JSONObject();
   List<String> listXdata = new ArrayList<String>();
   List<Integer> incomeDataList = new ArrayList<Integer>();
   List<Highcharts> dataList = new ArrayList<Highcharts>();
   Highcharts incomeChart = new Highcharts();
   if (CollectionUtils.isNotEmpty(data)) {
     for (YwUser obj : data) {
       listXdata.add(sdf.format(obj.getCreateTime()).toString()); // 日期
       incomeDataList.add(obj.getRegiestCount()); // 当前日期注册数
       regCounts += obj.getRegiestCount(); // 总注册数
     }
   }
   incomeChart.setName("注册用户数");
   incomeChart.setData(incomeDataList);
   dataList.add(incomeChart);
   jsonData.put("regCounts", regCounts);
   jsonData.put("listYdata", dataList);
   jsonData.put("listXdata", listXdata);
   try {
     super.writeNoLog(jsonData);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  @Override
  public void execute() throws IOException {
    super.execute();

    if (CollectionUtils.isNotEmpty(failures)) {
      StringBuilder buf = new StringBuilder(String.format("%d failed builds: ", failures.size()));
      String indent = StringUtils.repeat(" ", 10);

      for (FailedBuild failedBuild : failures) {
        buf.append("\n")
            .append(indent)
            .append(
                String.format(
                    "[%s] Build Number: %d",
                    failedBuild.job.getName(), failedBuild.build.getNumber()));
        buf.append("\n")
            .append(indent)
            .append(
                String.format(
                    "[%s] URL: %s",
                    failedBuild.job.getName(), String.valueOf(failedBuild.build.getUrl())));
      }

      logInfo(buf.toString());

      throw new IllegalArgumentException(String.format("%d failed builds found.", failures.size()));
    }
  }
  private void checkQueryOne(Query query) {
    Assert.assertEquals(query.getId(), "query-1");
    Assert.assertEquals(query.getBody(), "{'query' : 'body'}");
    Assert.assertEquals(query.getConverter(), "simpleDomainConverter");
    Assert.assertNotNull(query.getCases());
    Assert.assertTrue(CollectionUtils.isNotEmpty(query.getCases()));
    Assert.assertEquals(query.getCases().size(), 3);
    QueryCase queryCase1 = query.getQueryCaseById("caseOne");
    QueryCase queryCase2 = query.getQueryCaseById("caseTwo");
    QueryCase queryCase3 = query.getQueryCaseById("caseThree");
    Assert.assertEquals(queryCase1.getId(), "caseOne");
    Assert.assertEquals(queryCase1.getCondition(), "name == 'john'");
    Assert.assertEquals(queryCase1.getBody(), "{'case' : '#name'},{'body' : 'query-1-fragment'}");
    Assert.assertEquals(queryCase1.getConverter(), "simpleDomainConverter");
    Assert.assertEquals(queryCase1.getConverterMethod(), "customConvertMethod");
    Assert.assertEquals(queryCase1.getPriority(), 10);

    Assert.assertEquals(queryCase2.getId(), "caseTwo");
    Assert.assertEquals(queryCase2.getCondition(), "name == 'jack'");
    Assert.assertEquals(queryCase2.getBody(), "{'case' : '#name'}");
    Assert.assertEquals(queryCase2.getConverter(), null);
    Assert.assertEquals(queryCase2.getConverterMethod(), null);
    Assert.assertEquals(queryCase2.getPriority(), 5);

    Assert.assertEquals(queryCase3.getId(), "caseThree");
    Assert.assertEquals(queryCase3.getCondition(), "name == 'jack'");
    Assert.assertEquals(queryCase3.getBody(), "{'case' : '#name'}");
    Assert.assertEquals(queryCase3.getConverter(), "simpleDomainConverter");
    Assert.assertEquals(queryCase3.getConverterMethod(), "customConvertMethod");
    Assert.assertEquals(queryCase3.getPriority(), 0);
  }
 protected void assignResponsibilityIds(PeopleFlowBo peopleFlowBo) {
   if (CollectionUtils.isNotEmpty(peopleFlowBo.getMembers())) {
     for (PeopleFlowMemberBo memberBo : peopleFlowBo.getMembers()) {
       if (StringUtils.isBlank(memberBo.getResponsibilityId())) {
         memberBo.setResponsibilityId(responsibilityIdService.getNewResponsibilityId());
       }
       if (CollectionUtils.isNotEmpty(memberBo.getDelegates())) {
         for (PeopleFlowDelegateBo delegateBo : memberBo.getDelegates()) {
           if (StringUtils.isBlank(delegateBo.getResponsibilityId())) {
             delegateBo.setResponsibilityId(responsibilityIdService.getNewResponsibilityId());
           }
         }
       }
     }
   }
 }
 @RequestMapping(params = "methodToCall=viewRequestedRecords")
 public ModelAndView viewRequestedRecords(
     @ModelAttribute("KualiForm") UifFormBase form,
     BindingResult result,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   OLEItemRequestedRecordsForm oleItemRequestedRecordsForm = (OLEItemRequestedRecordsForm) form;
   String itemBarcode = request.getParameter(OLEConstants.OleDeliverRequest.ITEM_BARCODE);
   if (StringUtils.isNotBlank(itemBarcode)) {
     Map itemMap = new HashMap();
     itemMap.put(OLEConstants.OleDeliverRequest.ITEM_ID, itemBarcode);
     List<OleDeliverRequestBo> deliverRequestBos =
         (List<OleDeliverRequestBo>)
             KRADServiceLocator.getBusinessObjectService()
                 .findMatching(OleDeliverRequestBo.class, itemMap);
     if (CollectionUtils.isNotEmpty(deliverRequestBos)) {
       for (int i = 0; i < deliverRequestBos.size(); i++) {
         getOleDeliverRequestDocumentHelperService().processItem(deliverRequestBos.get(i));
       }
       oleItemRequestedRecordsForm.setRequestBos(deliverRequestBos);
     }
   }
   return getUIFModelAndView(oleItemRequestedRecordsForm, "OLEItemRequestedRecordPage");
 }
 /** @return the recepcionProveedorDTO */
 public RecepcionProveedorDTO getRecepcionProveedorActivo() {
   recepcionProveedorActivo = null;
   if (CollectionUtils.isNotEmpty(recepcionProveedorDTOCol)) {
     recepcionProveedorActivo = this.recepcionProveedorDTOCol.iterator().next();
   }
   return recepcionProveedorActivo;
 }
示例#27
0
 /**
  * @param userId
  * @return @Description:查询所有角色。标记用户已经拥有的角色
  */
 @ResponseBody
 @RequestMapping("/getRoles")
 @Permission(systemSn = "privilege", moduleSn = "user", value = PermissionConatant.R)
 public String getRoles(String userId, Role role, Query query) {
   PagerModel<Role> pm = null;
   List<Role> roles = null;
   List<Role> uroles = null;
   try {
     pm = this.roleService.getPagerModel(role, query);
     if (pm != null && CollectionUtils.isNotEmpty(pm.getDatas())) {
       roles = pm.getDatas();
       uroles = this.userRoleService.getRolesByUserId(userId);
       if (uroles != null && uroles.size() > 0) {
         for (Role ur : uroles) {
           for (Role r : roles) {
             if (ur.getId().equals(r.getId())) {
               r.setChecked(true);
               break;
             }
           }
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     logger.debug("UserController-getRoles:" + e.getMessage());
   }
   return JsonUtils.toJson(roles);
 }
示例#28
0
  private List<Linkable> findPossibleEntryPoints(
      final SecurityContext securityContext, HttpServletRequest request, final String path)
      throws FrameworkException {

    List<Linkable> possibleEntryPoints =
        (List<Linkable>) request.getAttribute(POSSIBLE_ENTRY_POINTS);

    if (CollectionUtils.isNotEmpty(possibleEntryPoints)) {
      return possibleEntryPoints;
    }

    if (path.length() > 0) {

      logger.log(Level.FINE, "Requested name {0}", path);

      possibleEntryPoints = findPossibleEntryPointsByPath(securityContext, request, path);

      if (possibleEntryPoints.isEmpty()) {
        possibleEntryPoints =
            findPossibleEntryPointsByUuid(securityContext, request, PathHelper.getName(path));
      }

      return possibleEntryPoints;
    }

    return Collections.EMPTY_LIST;
  }
示例#29
0
  private List<Linkable> findPossibleEntryPointsByName(
      final SecurityContext securityContext, HttpServletRequest request, final String name)
      throws FrameworkException {

    List<Linkable> possibleEntryPoints =
        (List<Linkable>) request.getAttribute(POSSIBLE_ENTRY_POINTS);

    if (CollectionUtils.isNotEmpty(possibleEntryPoints)) {
      return possibleEntryPoints;
    }

    if (name.length() > 0) {

      logger.log(Level.FINE, "Requested name: {0}", name);

      final Query query = StructrApp.getInstance(securityContext).nodeQuery();

      query.and(AbstractNode.name, name);
      query.and().orType(Page.class).orTypes(File.class);

      // Searching for pages needs super user context anyway
      Result results = query.getResult();

      logger.log(Level.FINE, "{0} results", results.size());
      request.setAttribute(POSSIBLE_ENTRY_POINTS, results.getResults());

      return (List<Linkable>) results.getResults();
    }

    return Collections.EMPTY_LIST;
  }
  /**
   * Validate the AudienceRestriction of SAML2 Response
   *
   * @param assertion SAML2 Assertion
   * @return validity
   */
  private void validateAudienceRestriction(Assertion assertion) throws SAMLSSOException {

    if (assertion != null) {
      Conditions conditions = assertion.getConditions();
      if (conditions != null) {
        List<AudienceRestriction> audienceRestrictions = conditions.getAudienceRestrictions();
        if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
          for (AudienceRestriction audienceRestriction : audienceRestrictions) {
            if (CollectionUtils.isNotEmpty(audienceRestriction.getAudiences())) {
              boolean audienceFound = false;
              for (Audience audience : audienceRestriction.getAudiences()) {
                if (properties
                    .get(IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID)
                    .equals(audience.getAudienceURI())) {
                  audienceFound = true;
                  break;
                }
              }
              if (!audienceFound) {
                throw new SAMLSSOException("SAML Assertion Audience Restriction validation failed");
              }
            } else {
              throw new SAMLSSOException(
                  "SAML Response's AudienceRestriction doesn't contain Audiences");
            }
          }
        } else {
          throw new SAMLSSOException("SAML Response doesn't contain AudienceRestrictions");
        }
      } else {
        throw new SAMLSSOException("SAML Response doesn't contain Conditions");
      }
    }
  }