List of usage examples for java.util List retainAll
boolean retainAll(Collection<?> c);
From source file:org.objectstyle.cayenne.wocompat.EOModelHelper.java
/** * Creates helper instance and tries to locate EOModel and load index file. *//*www .ja v a 2 s. c om*/ public EOModelHelper(String path) throws Exception { this.modelUrl = findModelUrl(path); this.dataMap = new DataMap(findModelName(path)); // load index file List modelIndex = (List) loadModelIndex().get("entities"); // load entity indices entityIndex = new HashMap(); entityClassIndex = new HashMap(); entityClientClassIndex = new HashMap(); entityQueryIndex = new HashMap(); Iterator it = modelIndex.iterator(); while (it.hasNext()) { Map info = (Map) it.next(); String name = (String) info.get("name"); entityIndex.put(name, loadEntityIndex(name)); entityQueryIndex.put(name, loadQueryIndex(name)); entityClassIndex.put(name, info.get("className")); Map entityPlistMap = entityPListMap(name); // get client class information Map internalInfo = (Map) entityPlistMap.get("internalInfo"); if (internalInfo != null) { String clientClassName = (String) internalInfo.get("_javaClientClassName"); entityClientClassIndex.put(name, clientClassName); } } it = modelIndex.iterator(); while (it.hasNext()) { Map info = (Map) it.next(); String name = (String) info.get("name"); Map entityPlistMap = entityPListMap(name); List classProperties = (List) entityPlistMap.get("classProperties"); if (classProperties == null) { classProperties = Collections.EMPTY_LIST; } // get client class information Map internalInfo = (Map) entityPlistMap.get("internalInfo"); List clientClassProperties = (internalInfo != null) ? (List) internalInfo.get("_clientClassPropertyNames") : null; // guard against no internal info and no client class properties if (clientClassProperties == null) { clientClassProperties = Collections.EMPTY_LIST; } // there is a bug in EOModeler it sometimes keeps outdated properties in // the client property list. This removes them clientClassProperties.retainAll(classProperties); // remove all properties from the entity properties that are already defined // in // a potential parent class. String parentEntity = (String) entityPlistMap.get("parent"); while (parentEntity != null) { Map parentEntityPListMap = entityPListMap(parentEntity); List parentClassProps = (List) parentEntityPListMap.get("classProperties"); classProperties.removeAll(parentClassProps); // get client class information of parent Map parentInternalInfo = (Map) parentEntityPListMap.get("internalInfo"); if (parentInternalInfo != null) { List parentClientClassProps = (List) parentInternalInfo.get("_clientClassPropertyNames"); clientClassProperties.removeAll(parentClientClassProps); } parentEntity = (String) parentEntityPListMap.get("parent"); } // put back processed properties to the map entityPlistMap.put("classProperties", classProperties); // add client classes directly for easier access entityPlistMap.put("clientClassProperties", clientClassProperties); } }
From source file:org.rhq.enterprise.server.resource.metadata.ResourceMetadataManagerBean.java
private void updateSubCategory(ResourceSubCategory existingSubCat, ResourceSubCategory newSubCategory) { // update the basic properties existingSubCat.update(newSubCategory); // we'll do the removal of all child subcategories that are in the existing subcat but not in the new one // once the child resource types have had a chance to stop referencing any old subcategories // Easy case: If the existing sub category did not have any child sub categories, // simply use the ones from the new type if ((existingSubCat.getChildSubCategories() == null) || existingSubCat.getChildSubCategories().isEmpty()) { for (ResourceSubCategory newChildSubCategory : newSubCategory.getChildSubCategories()) { log.debug("Metadata update: Adding new child SubCategory [" + newChildSubCategory.getName() + "] to SubCategory [" + existingSubCat.getName() + "]..."); existingSubCat.addChildSubCategory(newChildSubCategory); entityManager.persist(newChildSubCategory); }/*from w ww . j a v a2 s . c o m*/ return; } // Merge definitions that were already in the existing sub cat and also in the new one // // First, put the new child sub categories in a map for easier access when iterating over the existing ones Map<String, ResourceSubCategory> childSubCategoriesFromNewSubCat = new HashMap<String, ResourceSubCategory>( newSubCategory.getChildSubCategories().size()); for (ResourceSubCategory newChildSubCategory : newSubCategory.getChildSubCategories()) { childSubCategoriesFromNewSubCat.put(newChildSubCategory.getName(), newChildSubCategory); } // Second, loop over the sub categories that need to be merged and update and persist them List<ResourceSubCategory> mergedChildSubCategories = new ArrayList<ResourceSubCategory>( existingSubCat.getChildSubCategories()); mergedChildSubCategories.retainAll(childSubCategoriesFromNewSubCat.values()); for (ResourceSubCategory existingChildSubCategory : mergedChildSubCategories) { // recursively update childSubCategory updateSubCategory(existingChildSubCategory, childSubCategoriesFromNewSubCat.get(existingChildSubCategory.getName())); entityManager.merge(existingChildSubCategory); } // Persist all new definitions List<ResourceSubCategory> newChildSubCategories = new ArrayList<ResourceSubCategory>( newSubCategory.getChildSubCategories()); newChildSubCategories.removeAll(existingSubCat.getChildSubCategories()); for (ResourceSubCategory newChildSubCategory : newChildSubCategories) { log.info("Metadata update: Adding new child SubCategory [" + newChildSubCategory.getName() + "] to SubCategory [" + existingSubCat.getName() + "]..."); existingSubCat.addChildSubCategory(newChildSubCategory); entityManager.persist(newChildSubCategory); } }
From source file:backup.SearchPatientReportCon.java
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.GET) public String searchTest(@RequestParam(value = "date", required = false) String dateStr, @RequestParam(value = "patientId") Integer patientId, @RequestParam(value = "investigation", required = false) String investigation, HttpServletRequest request, Model model) { LaboratoryService ls = (LaboratoryService) Context.getService(LaboratoryService.class); LabService labSer = Context.getService(LabService.class); MedisunService ms = Context.getService(MedisunService.class); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Date date = null;//from ww w . j ava 2 s . com try { date = sdf.parse(dateStr); Patient patient = Context.getPatientService().getPatient(patientId); List<TestModelNew> tmn = new ArrayList<TestModelNew>(); //String ob=null; List<LabTest> te = Context.getService(LaboratoryService.class).getLaboratoryTestsByDateAndPatient(date, patient); // Patient information if (patient != null) { model.addAttribute("patient_identifier", patient.getPatientIdentifier().getIdentifier()); model.addAttribute("patient_age", patient.getAge()); model.addAttribute("patient_gender", patient.getGender()); model.addAttribute("patient_name", PatientUtils.getFullName(patient)); model.addAttribute("test_orderDate", date); model.addAttribute("dDate", new Date()); Date birthday = patient.getBirthdate(); //model.addAttribute("age", PatientUtils.estimateAge(birthday)); model.addAttribute("age", patient.getAge()); } List<DiaInvestigationSpecimen> diaSpcList = ls.getAllDiaSpecimen(); //c1.retainAll(c2); // te.retainAll(diaSpcList); List<Integer> l1 = new ArrayList<Integer>(); Integer blood; for (int i = 0; i < diaSpcList.size(); i++) {//using loop // blood= diaSpcList.get(i).getBlood(); // l1.add(blood); } List<Integer> l2 = new ArrayList<Integer>(); Integer pres; for (int i = 0; i < te.size(); i++) {//using loop pres = te.get(i).getConcept().getId(); l2.add(pres); } List<Integer> l3 = new ArrayList<Integer>(l2);//second obj k temporary akhane rakha hoase l1.retainAll(l3); model.addAttribute("l1", l1); model.addAttribute("l2", l2); model.addAttribute("l3", l3); /* Set<DiaInvestigationSpecimen> set1 = new HashSet<DiaInvestigationSpecimen>(); set1.addAll(diaSpcList); Set<LabTest> set2 = new HashSet<LabTest>(); set2.addAll(te); if(set2.equals(set1)){ model.addAttribute("abc", "Blood"); } Integer kha; int param = 2; for (int i = 0; i < te.size(); i++) { kha = i; if (kha== param) { break; } */ for (LabTest test : te) { Integer abc = test.getConcept().getId(); DiaInvestigationSpecimen diaSpe = ls.getDiaSepByConceptId(abc); model.addAttribute("a", abc); model.addAttribute("b", diaSpe); Integer orderId = test.getOrder().getId(); DiaPatientServiceBillItem dBillItem = labSer.getDiPatientBillItemByOrderId(orderId); Integer refBy = dBillItem.getDiaPatientServiceBill().getRefDocId(); DocDetail docInfo = ms.getDocInfoById(refBy); model.addAttribute("refBy", docInfo); // model.addAttribute("refBy",docInfo.getDoctorName() ); if ((test.getEncounter().getId() != null) && (test.getConcept().getConceptClass().getName().equalsIgnoreCase("LabSet"))) /* || (test.getConcept().getId() == 2920) && (test.getConcept().getId() == 2577) && (test.getConcept().getId() == 5239) && (test.getConcept().getId() == 5240) && (test.getConcept().getId() == 2404) && (test.getConcept().getId() == 2543) && (test.getConcept().getId() == 2407) ) */ { Encounter encounter = test.getEncounter(); for (Obs obs : encounter.getAllObs()) { TestModelNew t = new TestModelNew(); Concept concept = Context.getConceptService().getConcept(obs.getConcept().getConceptId()); t.setTest(obs.getValueText()); // result t.setGroupName(test.getConcept().getId().toString()); t.setInvestigation(obs.getConcept().getId().toString()); // test id t.setTestName(obs.getConcept().getName().getName()); // test name t.setEncounterId(obs.getEncounter().getId()); String datatype = concept.getDatatype().getName(); if (datatype.equalsIgnoreCase("Text")) { t.setValue(obs.getValueText()); } else if (datatype.equalsIgnoreCase("Numeric")) { if (obs.getValueText() != null) { t.setValue(obs.getValueText().toString()); } else { t.setValue(obs.getValueNumeric().toString()); } DiaConceptNumeric dia = Context.getService(LabService.class) .getDiaConNumByConId(concept.getConceptId()); if (dia.getConceptId() != null) { String d = dia.getRefRange(); String[] dd = d.split("#"); String ddd = StringUtils.join(dd, "<br>"); // t.setRefRange(dia.getRefRange()); t.setRefRange(ddd); } ConceptNumeric cn = Context.getConceptService() .getConceptNumeric(concept.getConceptId()); t.setUnit(cn.getUnits()); if (cn.getLowNormal() != null) { t.setLowNormal(cn.getLowNormal().toString()); } if (cn.getHiNormal() != null) { t.setHiNormal(cn.getHiNormal().toString()); } } else if (datatype.equalsIgnoreCase("Coded")) { t.setValue(obs.getValueCoded().getName().getName()); } //ob+=obs.getConcept().getId(); tmn.add(t); model.addAttribute("status", test.getConcept().getId()); } } } model.addAttribute("te", te); model.addAttribute("tmn", tmn); if (patient != null) { List<LabTest> tests = ls.getLaboratoryTestsByDateAndPatient(date, patient); if ((tests != null) && (!tests.isEmpty())) { Map<Concept, Set<Concept>> testTreeMap = (Map<Concept, Set<Concept>>) request.getSession() .getAttribute(LaboratoryConstants.SESSION_TEST_TREE_MAP); List<TestResultModel> trms = renderTests(tests, testTreeMap); trms = formatTestResult(trms); model.addAttribute("tests", trms); model.addAttribute("investigation", investigation); } } } catch (ParseException e) { e.printStackTrace(); System.out.println("Error when parsing order date!"); return null; } return "/module/laboratory/patientreport/search"; }
From source file:cepdest.pattern.holder.EnhancedPatternsHolder.java
@Override public void insertNewItinerary(Itinerary it) { if (it.getNumOfAllNamedAreas() > 1) { String patternId = null;//w w w . ja va 2 s . co m AreaOfInterest a1 = it.getAllNamedAreas().get(it.getNumOfAllNamedAreas() - 2); AreaOfInterest a2 = it.getAllNamedAreas().get(it.getNumOfAllNamedAreas() - 1); EnhancedPatternNode node1 = getNodeWithArea(a1); EnhancedPatternNode lastNode = getNodeWithArea(a2); Set<String> outPatternIds = lastNode.getPatternIds(); List<String> prevPatternIds = node1.getPatternIdsForSon(a2.getID()); if (prevPatternIds != null) { if (outPatternIds != null) { prevPatternIds.removeAll(outPatternIds); } int init = it.getNumOfAllNamedAreas() - 2; a2 = a1; for (int i = init; i > 0; i--) { a1 = it.getAllNamedAreas().get(i - 1); EnhancedPatternNode node = getNodeWithArea(a1); List<String> patternIds = node.getPatternIdsForSon(a2.getID()); if (patternIds == null) { break; } prevPatternIds.retainAll(patternIds); if (prevPatternIds.size() == 1) { patternId = prevPatternIds.get(0); break; } a2 = a1; } } if (patternId == null) { a1 = it.getAllNamedAreas().get(0); node1 = getNodeWithArea(a1); patternId = node1.createNewOwnPatternId(); } insertNewItineraryWithPatternId(it, patternId); } }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractHomeController.java
@RequestMapping(value = { "/home" }) public String home(@ModelAttribute("currentTenant") Tenant tenant, @RequestParam(value = "tenant", required = false) String tenantParam, @RequestParam(value = "secondLevel", required = false) boolean secondLevel, ModelMap map, HttpSession session, HttpServletRequest request) throws ConnectorManagementServiceException { logger.debug("###Entering in home(map) method"); map.addAttribute("maintenance", healthService.listPlannedNotifications(null)); map.addAttribute("showWarningOfServiceInstanceNotEnabled", true); User user = getCurrentUser();//from w w w. j a v a 2 s. c o m // setting login success message only when request come from login page. if (session.getAttribute("loginreturn") != null && session.getAttribute("loginreturn").equals("success")) { map.addAttribute("return_message", "true"); map.addAttribute("return_message_type", "info"); session.removeAttribute("loginreturn"); } if (!(config.getBooleanValue(Configuration.Names.com_citrix_cpbm_portal_directory_service_enabled))) { if (user.getPassword() == null) { map.clear(); return "redirect:/portal/users/" + user.getParam() + "/myprofile"; } } if ((user.getFirstName() == null || user.getFirstName().isEmpty()) || (user.getLastName() == null || user.getLastName().isEmpty())) { map.clear(); return "redirect:/portal/users/" + user.getParam() + "/myprofile"; } List<String> currentUserServiceCategoryList = userService.getAllAccessibleCloudServiceCategories(user); tenant = (Tenant) request.getAttribute(UserContextInterceptor.EFFECTIVE_TENANT_KEY); if ((userService.hasAnyAuthority(user, "ROLE_ACCOUNT_CRUD", "ROLE_ACCOUNT_MGMT", "ROLE_FINANCE_CRUD")) && (Boolean) request.getAttribute("isSurrogatedTenant")) { user = tenant.getOwner(); map.addAttribute("showUserProfile", true); setPage(map, Page.CRM_HOME); } else { setPage(map, Page.HOME); } fetchEvents(user, map); map.addAttribute("userHasCloudServiceAccount", userService.isUserHasAnyActiveCloudService(user)); if (!userService.hasAuthority(user, "ROLE_TICKET_MANAGEMENT") && !tenant.getAccountId().equals(TenantService.SYSTEM_TENANT)) { if (user.equals(user.getTenant().getOwner()) || userService.hasAuthority(user, "ROLE_ACCOUNT_BILLING_ADMIN") || userService.hasAuthority(user, "ROLE_ACCOUNT_ADMIN")) { try { AccountStatement provisionalAccountStatement = billingService .getOrCreateProvisionalAccountStatement(tenant); HashMap<String, Object> spendVsBudgetChartData = reportService.getChartData(user, "tenant", getSessionLocale(request), provisionalAccountStatement); map.addAttribute("chartData", JSONUtils.toJSONString(spendVsBudgetChartData)); map.addAttribute("spend_vs_budget_chart_data_obj", spendVsBudgetChartData); addToChartData(map, provisionalAccountStatement); } catch (Exception e) { logger.error("Caught Exception while getting chart data", e); map.addAttribute("chartData", null); } } else { try { map.addAttribute("chartData", JSONUtils .toJSONString(reportService.getChartData(user, "user", getSessionLocale(request)))); } catch (Exception e) { logger.error("Caught Exception while getting chart data", e); map.addAttribute("chartData", null); } } } // Showing only four tasks on the dashboard Map<Task, String> taskUrlMap = taskService.getPendingTasksMap(tenant, user, 1, 4); map.addAttribute("taskUrlMap", taskUrlMap); map.addAttribute("tickets", null); map.addAttribute("totalTickets", 0); List<User> usersUnderTenant = userService.list(0, 0, null, null, false, null, tenant.getId().toString(), null); map.addAttribute("users", usersUnderTenant); map.addAttribute("isOwner", getCurrentUser().equals(tenant.getOwner())); map.addAttribute("user", user); // check user limit int userLimit; if (tenant.getMaxUsers() != null) { userLimit = tenant.getMaxUsers().intValue(); } else { userLimit = tenant.getAccountType().getMaxUsers().intValue(); } int noOfUsers = usersUnderTenant.size(); if (userLimit >= 0 && noOfUsers >= userLimit) { map.addAttribute("isUsersMaxReached", "Y"); } map.addAttribute("currentDate", new Date()); map.addAttribute("tenant", tenant); List<ServiceInstance> ticketTypeServiceInstance = userService.getServiceInstance(user, "OSS", "TICKET"); BaseConnector ticketTypeConnector = connectorManagementService .getOssServiceInstancebycategory(ConnectorType.TICKET); if (!ticketTypeServiceInstance.isEmpty() || (ticketTypeConnector != null && user.isEnabled() && !user.isLocked())) { map.addAttribute("ticketServiceInstance", true); } else { map.addAttribute("ticketServiceInstance", false); } // Fetching category list and prepending it with All category List<String> serviceCategoryList = userService.getAllAccessibleCloudServiceCategories(user); serviceCategoryList.retainAll(currentUserServiceCategoryList); serviceCategoryList.add(0, CssdkConstants.ALL); map.addAttribute("serviceCategoryList", serviceCategoryList); // populate custom fields customFieldService.populateCustomFields(user); customFieldService.populateCustomFields(user.getTenant()); // Intances added for service health List<ServiceInstance> cloudTypeServiceInstances = userService.getCloudServiceInstance(user, null); map.addAttribute("cloudTypeServiceInstances", cloudTypeServiceInstances); String view = null; if (tenant.equals(tenantService.getSystemTenant())) { HashMap<String, Object> parameters = new HashMap<String, Object>(); Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance(); DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); start.add(Calendar.DATE, -7); parameters.put("startDate", format.format(start.getTime())); parameters.put("endDate", format.format(end.getTime())); List<AccountType> accountTypeList = tenantService.getAllAccountTypes(); accountTypeList.remove(tenantService.getAccountTypeByName("SYSTEM")); GenericReport nrr = new NewRegistrationReport(parameters, dataSource, accountTypeList, getSessionLocale(request), messageSource); Report reportFusionNR = null; reportFusionNR = reportService.generateFusionReport(nrr); reportFusionNR.getAttributes().put("chartId", "HomeNewReg"); reportFusionNR.getAttributes().put("fusionChartType", "MSColumn2D"); map.addAttribute("reportFusionNR", reportFusionNR); HashMap<String, Object> parametersCR = new HashMap<String, Object>(); parametersCR.put("month", Calendar.getInstance().get(Calendar.MONTH) + 1); parametersCR.put("year", Calendar.getInstance().get(Calendar.YEAR)); parametersCR.put("defaultCurrency", messageSource.getMessage( "currency.symbol." + config.getValue(Names.com_citrix_cpbm_portal_settings_default_currency), null, getSessionLocale(request))); GenericReport crr = new CustomerRankReport(parametersCR, dataSource, config, getSessionLocale(request), messageSource); Report reportFusionCR = null; reportFusionCR = reportService.generateFusionReport(crr); reportFusionCR.getAttributes().put("chartId", "HomeCustRank"); reportFusionCR.getAttributes().put("fusionChartType", "Column2D"); map.addAttribute("reportFusionCR", reportFusionCR); map.addAttribute("showCloudConsoleLink", true); view = "main.home_service_with_second_level"; } else { AccountStatement accountStatement = billingAdminService.getOrCreateProvisionalAccountStatement(tenant); map.addAttribute("currentBillingStart", accountStatement.getBillingPeriodStartDate()); Date nextInvoiceDate = DateUtils.addOneDay(accountStatement.getBillingPeriodEndDate()); map.addAttribute("nextInvoiceDate", nextInvoiceDate); view = "main.home_with_second_level"; } logger.debug("###Exiting home(map) method"); return view; }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractConnectorController.java
@RequestMapping(value = "/service_instance_list", method = RequestMethod.GET) @ResponseBody// w ww.j a v a 2 s . c om public List<Map<String, String>> getServiceInstanceList(@ModelAttribute("currentTenant") Tenant currentTenant, @RequestParam(value = "tenant", required = false) String tenantParam, @RequestParam(value = "viewCatalog", required = false, defaultValue = "false") Boolean viewCatalog, @RequestParam(value = "category", required = false) String category, HttpServletRequest request) { logger.debug("###Entering in getServiceInstanceList GET"); User user = getCurrentUser(); if (user == null || viewCatalog && user.getTenant().equals(tenantService.getSystemTenant())) { user = userService.getSystemUser(Handle.PORTAL); } List<ServiceInstance> serviceProviderCloudTypeServiceInstances = new ArrayList<ServiceInstance>(); boolean isSurrogatedTenant = (Boolean) request.getAttribute("isSurrogatedTenant"); if (isSurrogatedTenant) { serviceProviderCloudTypeServiceInstances = userService.getCloudServiceInstance(user, category); user = tenantService.get(tenantParam).getOwner(); } List<ServiceInstance> cloudTypeServiceInstances = userService.getCloudServiceInstance(user, category); if (isSurrogatedTenant) { cloudTypeServiceInstances.retainAll(serviceProviderCloudTypeServiceInstances); } List<Map<String, String>> serviceInstanceValues = new ArrayList<Map<String, String>>(); for (ServiceInstance currentInstance : cloudTypeServiceInstances) { Map<String, String> currentInstanceValues = new HashMap<String, String>(); currentInstanceValues.put("uuid", currentInstance.getUuid()); currentInstanceValues.put("name", currentInstance.getName()); serviceInstanceValues.add(currentInstanceValues); } return serviceInstanceValues; }
From source file:com.microsoft.tfs.core.clients.workitem.internal.rules.FieldPickListSupport.java
public AllowedValuesCollection getAllowedValues() { if (allowedValues == null) { final List<String> pickList = new ArrayList<String>(); if (suggested == null && allowed == null) { if (log.isDebugEnabled()) { log.debug(MessageFormat.format( "{0}: computed non-existing picklist, since suggested and allowed are null", //$NON-NLS-1$ debuggingIdentifier)); }//from ww w . j a va 2 s. co m } else { if (suggested != null) { pickList.addAll(suggested); if (log.isDebugEnabled()) { log.debug(MessageFormat.format( "{0}: computing picklist, added {1} suggested values, pick list size = {2}", //$NON-NLS-1$ debuggingIdentifier, suggested.size(), pickList.size())); } if (allowed != null) { pickList.retainAll(allowed); if (log.isDebugEnabled()) { log.debug(MessageFormat.format( "{0}: computing picklist, retained {1} allowed values, pick list size = {2}", //$NON-NLS-1$ debuggingIdentifier, allowed.size(), pickList.size())); } } } else { pickList.addAll(allowed); if (log.isDebugEnabled()) { log.debug(MessageFormat.format( "{0}: computing picklist, added {1} allowed values, pick list size = {2}", //$NON-NLS-1$ debuggingIdentifier, allowed.size(), pickList.size())); } } if (prohibited != null) { pickList.removeAll(prohibited); if (log.isDebugEnabled()) { log.debug(MessageFormat.format( "{0}: computing picklist, removed {1} prohibited values, pick list size = {2}", //$NON-NLS-1$ debuggingIdentifier, prohibited.size(), pickList.size())); } } /* * null values are needed for data validation (implicit empty), * but don't show them in the picklist * * TODO: I think this is old code and can be removed. Pretty * sure the RuleEngine never adds null to a FieldPickListSupport * any more, but need to check this before removing this line. */ pickList.remove(null); /* * NOTE: we used to check here if the pick list size was empty, * and if so set to null. The behavior was that if a pick list * is empty, no pick list exists. * * It seems that the MS OM does not do this - if a pick list is * empty a field still has a pick list. Our code was changed to * act the same way. The main implication is that on the work * item form we show an empty combobox in this case instead of a * text box. */ } /* * Create AllowedValueCollection from list. */ final String[] values = pickList.toArray(new String[pickList.size()]); allowedValues = new AllowedValuesCollectionImpl(values, psType); } return allowedValues; }
From source file:nl.strohalm.cyclos.webservices.utils.PaymentHelper.java
/** * Lists the possible transfer types for this payment *//*w ww. ja va 2s . c om*/ public Collection<TransferType> listPossibleTypes(final DoPaymentDTO dto) { final String channel = channelHelper.restricted(); if (StringUtils.isEmpty(channel)) { return Collections.emptyList(); } final Member member = WebServiceContext.getMember(); final ServiceClient client = WebServiceContext.getClient(); // First, we need a list of existing TTs for the payment final TransferTypeQuery query = new TransferTypeQuery(); query.setResultType(ResultType.LIST); query.setContext(TransactionContext.PAYMENT); query.setChannel(channel); query.setFromOwner(dto.getFrom()); query.setToOwner(dto.getTo()); query.setCurrency(dto.getCurrency()); final List<TransferType> transferTypes = transferTypeServiceLocal.search(query); // Then, restrict according to the web service client permissions boolean doPayment = true; if (member != null) { doPayment = member.equals(dto.getFrom()); } Collection<TransferType> possibleTypes; if (doPayment) { possibleTypes = serviceClientServiceLocal .load(client.getId(), ServiceClient.Relationships.DO_PAYMENT_TYPES).getDoPaymentTypes(); } else { possibleTypes = serviceClientServiceLocal .load(client.getId(), ServiceClient.Relationships.RECEIVE_PAYMENT_TYPES) .getReceivePaymentTypes(); } transferTypes.retainAll(possibleTypes); return transferTypes; }
From source file:org.squashtest.tm.service.internal.testcase.CustomTestCaseModificationServiceImpl.java
/** * @see org.squashtest.tm.service.testcase.CustomTestCaseFinder#findCallingTCids(long, Collection) */// ww w . ja v a 2 s.c o m @Override public Set<Long> findCallingTCids(long updatedId, Collection<Long> callingCandidates) { List<Long> callingCandidatesClone = new ArrayList<>(callingCandidates); List<Long> callingLayer = testCaseDao.findAllTestCasesIdsCallingTestCases(Arrays.asList(updatedId)); Set<Long> callingTCToUpdate = new HashSet<>(); while (!callingLayer.isEmpty() && !callingCandidatesClone.isEmpty()) { // filter found calling test cases callingLayer.retainAll(callingCandidatesClone); // save callingTCToUpdate.addAll(callingLayer); // reduce test case of interest callingCandidatesClone.removeAll(callingLayer); // go next layer callingLayer = testCaseDao.findAllTestCasesIdsCallingTestCases(callingLayer); } return callingTCToUpdate; }
From source file:com.ichi2.anki.tests.libanki.ImportTest.java
public void testAnki2Mediadupes() throws IOException, JSONException { List<String> expected; List<String> actual; Collection tmp = Shared.getEmptyCol(getContext()); // add a note that references a sound Note n = tmp.newNote();/*from w w w. j av a 2s . c o m*/ n.setItem("Front", "[sound:foo.mp3]"); long mid = n.model().getLong("id"); tmp.addNote(n); // add that sound to the media folder FileOutputStream os; os = new FileOutputStream(new File(tmp.getMedia().dir(), "foo.mp3"), false); os.write("foo".getBytes()); os.close(); tmp.close(); // it should be imported correctly into an empty deck Collection empty = Shared.getEmptyCol(getContext()); Importer imp = new Anki2Importer(empty, tmp.getPath()); imp.run(); expected = Arrays.asList("foo.mp3"); actual = Arrays.asList(new File(empty.getMedia().dir()).list()); actual.retainAll(expected); assertEquals(expected.size(), actual.size()); // and importing again will not duplicate, as the file content matches empty.remCards(Utils.arrayList2array(empty.getDb().queryColumn(Long.class, "select id from cards", 0))); imp = new Anki2Importer(empty, tmp.getPath()); imp.run(); expected = Arrays.asList("foo.mp3"); actual = Arrays.asList(new File(empty.getMedia().dir()).list()); actual.retainAll(expected); assertEquals(expected.size(), actual.size()); n = empty.getNote(empty.getDb().queryLongScalar("select id from notes")); assertTrue(n.getFields()[0].contains("foo.mp3")); // if the local file content is different, and import should trigger a rename empty.remCards(Utils.arrayList2array(empty.getDb().queryColumn(Long.class, "select id from cards", 0))); os = new FileOutputStream(new File(empty.getMedia().dir(), "foo.mp3"), false); os.write("bar".getBytes()); os.close(); imp = new Anki2Importer(empty, tmp.getPath()); imp.run(); expected = Arrays.asList("foo.mp3", String.format("foo_%s.mp3", mid)); actual = Arrays.asList(new File(empty.getMedia().dir()).list()); actual.retainAll(expected); assertEquals(expected.size(), actual.size()); n = empty.getNote(empty.getDb().queryLongScalar("select id from notes")); assertTrue(n.getFields()[0].contains("_")); // if the localized media file already exists, we rewrite the note and media empty.remCards(Utils.arrayList2array(empty.getDb().queryColumn(Long.class, "select id from cards", 0))); os = new FileOutputStream(new File(empty.getMedia().dir(), "foo.mp3")); os.write("bar".getBytes()); os.close(); imp = new Anki2Importer(empty, tmp.getPath()); imp.run(); expected = Arrays.asList("foo.mp3", String.format("foo_%s.mp3", mid)); actual = Arrays.asList(new File(empty.getMedia().dir()).list()); actual.retainAll(expected); assertEquals(expected.size(), actual.size()); n = empty.getNote(empty.getDb().queryLongScalar("select id from notes")); assertTrue(n.getFields()[0].contains("_")); }