List of usage examples for org.apache.commons.lang ArrayUtils contains
public static boolean contains(boolean[] array, boolean valueToFind)
Checks if the value is in the given array.
From source file:com.healthcit.cacure.businessdelegates.GeneratedModuleDataManager.java
private JSONArray generateFormDocuments(JSONArray modules, GeneratedModuleDataDetail moduleDetail) { log.debug("In generateFormDocuments method..."); log.debug(".................................."); log.debug(".................................."); // metadata associated with the module Map<String, String> metadata = getMetadataForModule(moduleDetail.getModuleId(), false); // number of documents to be generated per module int numFormsPerModule = moduleDetail.getActualNumberOfCouchDbDocuments() / moduleDetail.getActualNumberOfModules(); JSONObject[] documentArray = new JSONObject[moduleDetail.getActualNumberOfCouchDbDocuments()]; JSONArray documentJSONArray = new JSONArray(); log.debug("Number of modules generated: " + modules.size()); log.debug(/* w ww .ja va 2s . c o m*/ "Number of CouchDB documents to be generated: " + moduleDetail.getActualNumberOfCouchDbDocuments()); // Generate the documents in a multithreaded fashion List<Callable<Object>> tasks = new ArrayList<Callable<Object>>(); for (int index = 0; index < modules.size(); ++index) { Callable<Object> task = new GenerateCouchDbDocumentCommand(modules, index, numFormsPerModule, documentArray, metadata); tasks.add(task); } ConcurrentUtils.invokeBulkActions(tasks); // remove any null entries from the documentArray while (ArrayUtils.contains(documentArray, null)) { documentArray = (JSONObject[]) ArrayUtils.removeElement(documentArray, null); } // add the documents to the JSON array documentJSONArray.addAll(Arrays.asList(documentArray)); documentArray = null; //debugging log.debug("Number of documents actually generated and ready to save: " + documentJSONArray.size()); if (documentJSONArray.size() > 0) log.debug("First document to be saved: " + documentJSONArray.getJSONObject(0)); // return the JSON array return documentJSONArray; }
From source file:com.healthcit.analytics.dto.DataTableMapper.java
private static List<TableRow> generateDocumentBasedResultSet(JSONObject resultSet, String[] queryColumns) { List<TableRow> dataTableRows = new ArrayList<TableRow>(); // Get array of rows JSONArray rows = getRows(resultSet); for (Object row : rows) { // Get the actual document JSONObject document = getDocument((JSONObject) row); // Get the questions associated with the document JSONObject questions = getQuestions(document); // Get the form name associated with the document String formName = getFormName(document); // Get the form ID associated with the document String formId = getFormId(document); // Get the owner ID associated with the document String ownerId = getOwnerId(document); for (Object question : questions.values()) { // Get the questionText associated with each question String questionText = getQuestionText((JSONObject) question); // Get the questionId associated with each question String questionId = getQuestionId((JSONObject) question); // Get the answer values associated with each question JSONArray answerValues = getAnswerValues((JSONObject) question); for (Object ans : answerValues) { String answer = getAnswerValueText((JSONObject) ans); // Create a new TableRow with Form Name, Form ID, Owner ID, Question Text and Answer as its cells, // (depending on which columns were queried), // and add the new TableRow to the dataTableRows collection TableRow tableRow = new TableRow(); if (ArrayUtils.contains(queryColumns, ANSWERCOLUMN)) tableRow.addCell(answer); if (ArrayUtils.contains(queryColumns, QUESTIONTEXTCOLUMN)) tableRow.addCell(questionText); if (ArrayUtils.contains(queryColumns, QUESTIONIDCOLUMN)) tableRow.addCell(questionId); if (ArrayUtils.contains(queryColumns, FORMNAMECOLUMN)) tableRow.addCell(formName); if (ArrayUtils.contains(queryColumns, FORMIDCOLUMN)) tableRow.addCell(formId); if (ArrayUtils.contains(queryColumns, OWNERIDCOLUMN)) tableRow.addCell(ownerId); dataTableRows.add(tableRow); }//from w w w. ja va2s . c o m } } return dataTableRows; }
From source file:com.opengamma.integration.coppclark.CoppClarkExchangeFileReader.java
private int[] findIndices(String[] headers) { int[] indices = new int[INDEX_NOTES + 1]; indices[INDEX_MIC] = ArrayUtils.indexOf(headers, "MIC Code"); indices[INDEX_NAME] = ArrayUtils.indexOf(headers, "Exchange"); indices[INDEX_COUNTRY] = ArrayUtils.indexOf(headers, "ISO Code"); indices[INDEX_ZONE_ID] = ArrayUtils.indexOf(headers, "Olson time zone"); indices[INDEX_PRODUCT_GROUP] = ArrayUtils.indexOf(headers, "Group"); indices[INDEX_PRODUCT_NAME] = ArrayUtils.indexOf(headers, "Product"); indices[INDEX_PRODUCT_TYPE] = ArrayUtils.indexOf(headers, "Type"); indices[INDEX_PRODUCT_CODE] = ArrayUtils.indexOf(headers, "Code"); indices[INDEX_CALENDAR_START] = ArrayUtils.indexOf(headers, "Calendar Start"); indices[INDEX_CALENDAR_END] = ArrayUtils.indexOf(headers, "Calendar End"); indices[INDEX_DAY_START] = ArrayUtils.indexOf(headers, "Day Start"); indices[INDEX_DAY_RANGE_TYPE] = ArrayUtils.indexOf(headers, "Range Type"); indices[INDEX_DAY_END] = ArrayUtils.indexOf(headers, "Day End"); indices[INDEX_PHASE_NAME] = ArrayUtils.indexOf(headers, "Phase"); indices[INDEX_PHASE_TYPE] = ArrayUtils.indexOf(headers, "Phase Type"); indices[INDEX_PHASE_START] = ArrayUtils.indexOf(headers, "Phase Starts"); indices[INDEX_PHASE_END] = ArrayUtils.indexOf(headers, "Phase Ends"); indices[INDEX_RANDOM_START_MIN] = ArrayUtils.indexOf(headers, "Random Start Min"); indices[INDEX_RANDOM_START_MAX] = ArrayUtils.indexOf(headers, "Random Start Max"); indices[INDEX_RANDOM_END_MIN] = ArrayUtils.indexOf(headers, "Random End Min"); indices[INDEX_RANDOM_END_MAX] = ArrayUtils.indexOf(headers, "Random End Max"); indices[INDEX_LAST_CONFIRMED] = ArrayUtils.indexOf(headers, "Last Confirmed"); indices[INDEX_NOTES] = ArrayUtils.indexOf(headers, "Notes"); if (ArrayUtils.contains(indices, -1)) { throw new OpenGammaRuntimeException( "Column not found in exchange file (column must have been renamed!)"); }/*from w ww . jav a 2s .co m*/ return indices; }
From source file:com.adobe.acs.commons.workflow.bulk.execution.model.Workspace.java
public void removeActivePayload(Payload payload) { if (ArrayUtils.contains(activePayloads, payload.getDereferencedPath())) { activePayloads = (String[]) ArrayUtils.removeElement(activePayloads, payload.getDereferencedPath()); properties.put(PN_ACTIVE_PAYLOADS, activePayloads); }/*from w w w . java2 s. c om*/ }
From source file:gov.nih.nci.cabig.caaers.service.workflow.WorkflowServiceImpl.java
public List<ReviewStatus> allowedReviewStatuses(String loginId) { Map<ReviewStatus, Boolean> allowedReviewStatusMap = new HashMap<ReviewStatus, Boolean>(); try {//from w w w .j av a 2s . c o m List<UserGroupType> userGroupTypes = userRepository.getUserByLoginName(loginId).getUserGroupTypes(); //CAAERS-4586 //first fetch all the possible workflow configs. List<WorkflowConfig> workflowConfigList = workflowConfigDao.getAllWorkflowConfigs(); for (WorkflowConfig wc : workflowConfigList) { for (TaskConfig tc : wc.getTaskConfigs()) { for (Assignee assignee : tc.getAssignees()) { if (assignee.isUser()) { PersonAssignee personAssignee = (PersonAssignee) assignee; if (personAssignee.getPerson().getLoginId().equals(loginId)) { allowedReviewStatusMap.put(ReviewStatus.valueOf(tc.getStatusName()), true); } } else if (assignee.isRole()) { RoleAssignee roleAssignee = (RoleAssignee) assignee; PersonRole role = roleAssignee.getUserRole(); for (UserGroupType type : userGroupTypes) { if (ArrayUtils.contains(role.getUserGroups(), type)) { allowedReviewStatusMap.put(ReviewStatus.valueOf(tc.getStatusName()), true); break; } } } } } } } catch (CaaersNoSuchUserException noUser) { log.warn("No user is present within caAERS having loginId : " + loginId); } List<ReviewStatus> allowedReviewStatusList = new ArrayList<ReviewStatus>(allowedReviewStatusMap.keySet()); return allowedReviewStatusList; }
From source file:com.activecq.tools.flipbook.components.impl.FlipbookServiceImpl.java
public boolean isPageImplementation(Component component) { Component superComponent = component.getSuperComponent(); if (superComponent != null) { return this.isPageImplementation(superComponent); }/*from w w w . j a v a2s. co m*/ return ArrayUtils.contains(PAGE_RESOURCE_SUPER_TYPES, component.getResourceType()); }
From source file:com.athena.chameleon.engine.core.converter.FileEncodingConverter.java
/** * <pre>//w w w . ja v a2s . c om * * </pre> * @param file */ private void convertAll(File file) { if (file.isDirectory()) { // EJB Archive ? Exploded WEB Directory ? EJB Directory? ? . if (warFileList.contains(file) || jarFileList.contains(file)) { return; } fileSummary = fileSummaryMap.get(FileType.DIRECTORY); fileSummary.addCount(); File[] files = null; files = file.listFiles(); for (File f : files) { convertAll(f); } } else { String extension = file.getName().substring(file.getName().lastIndexOf(".") + 1).toLowerCase(); for (FileType fileType : fileTypes) { if (fileType.value().equals(extension)) { fileSummary = fileSummaryMap.get(fileType); fileSummary.addCount(); if (fileType.equals(FileType.JAR) && file.getParent().endsWith("lib")) { // xerces.jar, xalan.jar, xml-api.jar, jboss-*.jar ?? if (file.getName().startsWith("xerces") || file.getName().startsWith("xalan") || file.getName().startsWith("xml-api") || file.getName().startsWith("jboss-")) { // ? ?? ? analyzeDefinition.getDeleteLibraryList().add(file.getName()); //file.delete(); // ?? .bak ? . file.renameTo(new File(file.getAbsolutePath() + ".bak")); } else { // ?? ? ?? analyzeDefinition.getLibraryList().add(file.getName()); analyzeDefinition.getLibraryFullPathList().add(file.getAbsolutePath()); } continue; } // ? ? ?? ?? ? ? ? ?? ? ?? ?. if ((fileSummary.getSourceEncoding().equals("N/A") || fileSummary.getSourceEncoding().equals(policy.getDefaultEncoding())) && !fileType.equals(FileType.CLASS) && !fileType.equals(FileType.JAR)) { try { InputStream input = new FileInputStream(file); byte[] data = IOUtils.toByteArray(input, file.length()); IOUtils.closeQuietly(input); CharsetDetector detector = new CharsetDetector(); detector.setDeclaredEncoding(policy.getDefaultEncoding()); detector.setText(data); CharsetMatch cm = detector.detect(); fileSummary.setSourceEncoding(cm.getName()); if (policy.getConvertYn()) { fileSummary.setTargetEncoding(policy.getDefaultEncoding()); } } catch (FileNotFoundException e) { logger.error("FileNotFoundException has occurred.", e); } catch (IOException e) { logger.error("IOException has occurred.", e); } } } } // suffix property? ? ? ?? if (policy.getConvertYn() && ArrayUtils.contains(policy.getSuffix(), extension)) { executor.execute(new FileEncodingConvertTask(file, policy.getDefaultEncoding())); } } }
From source file:eionet.meta.service.EmailServiceImpl.java
/** * Parse LDAP role e-mail addresses and replace country code and member/collaborative country abbreviations. * * @param country/*from ww w. j a va 2 s . c om*/ * @return * @throws DirServiceException */ private String[] parseRoleAddresses(String country) throws DirServiceException { String recipients = Props.getRequiredProperty(PropsIF.SITE_CODE_ALLOCATE_NOTIFICATION_TO); recipients = StringUtils.replace(recipients, COUNTRY_CODE_PLACEHOLDER, country.toLowerCase()); String[] to = StringUtils.split(recipients, ","); for (int i = 0; i < to.length; i++) { if (to[i].contains(MC_CC_PLACEHOLDER)) { // test if it is member country String roleId = StringUtils.substringBefore(to[i], "@"); String mcRoleId = StringUtils.replace(roleId, MC_CC_PLACEHOLDER, MC); if (roleExists(mcRoleId)) { to[i] = StringUtils.replace(to[i], MC_CC_PLACEHOLDER, MC); continue; } // test if it is collaborative country country String ccRoleId = StringUtils.replace(roleId, MC_CC_PLACEHOLDER, CC); if (roleExists(ccRoleId)) { to[i] = StringUtils.replace(to[i], MC_CC_PLACEHOLDER, CC); } // could not if (to[i].contains(MC_CC_PLACEHOLDER)) { if (ArrayUtils.contains(MC_COUNTRIES, country.toLowerCase())) { StringUtils.replace(to[i], MC_CC_PLACEHOLDER, MC); } else { StringUtils.replace(to[i], MC_CC_PLACEHOLDER, CC); } } } } return to; }
From source file:com.healthcit.analytics.utils.CAHopeDataSourceUtils.java
private static ValueType getColumnDataType(String column, String[] numericColumns, String[] booleanColumns, String[] dateColumns) {/*from www . j a v a 2s . c o m*/ // the column data type ValueType columnDataType = null; // if this column was included in the request parameters as a numeric then declare it as such if (ArrayUtils.contains(numericColumns, column)) columnDataType = ValueType.NUMBER; // else, if this column was included in the request parameters as a boolean then declare it as such else if (ArrayUtils.contains(booleanColumns, column)) columnDataType = ValueType.BOOLEAN; // else, if this column was included in the request parameters as a date then declare it as such else if (ArrayUtils.contains(dateColumns, column)) columnDataType = ValueType.DATE; // else, declare it as a TEXT field (the default) else columnDataType = ValueType.TEXT; return columnDataType; }
From source file:biz.netcentric.cq.tools.actool.helper.AccessControlUtils.java
/** @param session admin session * @param path valid node path in CRX// ww w. ja va2 s . c om * @param authorizableIds ids of authorizables to be deleted from ACL of node specified by path * @return count ACEs that were removed */ public static int deleteAllEntriesForAuthorizableFromACL(final Session session, final String path, String[] authorizableIds) throws UnsupportedRepositoryOperationException, RepositoryException { final AccessControlManager accessControlManager = session.getAccessControlManager(); final JackrabbitAccessControlList acl = AccessControlUtils.getModifiableAcl(accessControlManager, path); if (acl == null) { // do nothing, if there is no content node at the given path return 0; } // get ACEs of the node final AccessControlEntry[] aces = acl.getAccessControlEntries(); int countRemoved = 0; // loop thorough ACEs and find the one of the given principal for (final AccessControlEntry ace : aces) { final JackrabbitAccessControlEntry jace = (JackrabbitAccessControlEntry) ace; if (ArrayUtils.contains(authorizableIds, jace.getPrincipal().getName())) { acl.removeAccessControlEntry(jace); // bind new policy accessControlManager.setPolicy(path, acl); countRemoved++; } } return countRemoved; }