List of usage examples for java.util Collection addAll
boolean addAll(Collection<? extends E> c);
From source file:edu.cornell.mannlib.vitro.webapp.auth.identifier.common.CommonIdentifierBundleFactory.java
/** * Get all Individuals associated with the current user. * /*from w w w. ja v a 2 s . c o m*/ * TODO Currently only uses the matching property. Should also use * "mayEditAs" type of association. */ private Collection<Individual> getAssociatedIndividuals(HttpServletRequest req) { Collection<Individual> individuals = new ArrayList<Individual>(); UserAccount user = LoginStatusBean.getCurrentUser(req); if (user == null) { log.debug("No Associated Individuals: not logged in."); return individuals; } WebappDaoFactory wdf = (WebappDaoFactory) context.getAttribute("webappDaoFactory"); if (wdf == null) { log.error("Could not get a WebappDaoFactory from the ServletContext"); return individuals; } IndividualDao indDao = wdf.getIndividualDao(); SelfEditingConfiguration sec = SelfEditingConfiguration.getBean(req); individuals.addAll(sec.getAssociatedIndividuals(indDao, user)); return individuals; }
From source file:net.sourceforge.fenixedu.domain.degreeStructure.DegreeModule.java
public Collection<CycleCourseGroup> getParentCycleCourseGroups() { Collection<CycleCourseGroup> res = new HashSet<CycleCourseGroup>(); for (CourseGroup courseGroup : getParentCourseGroups()) { res.addAll(courseGroup.getParentCycleCourseGroups()); }//w w w .j a va2s .c om return res; }
From source file:com.zb.app.websocket.server.WebSocketServerHandler.java
/** * ?ServerClient SessionInfo// ww w .ja v a 2s . c o m * * @return */ public Collection<SessionWrapper> getAllSessionInfo() { Collection<SessionWrapper> wsList = new ArrayList<SessionWrapper>(); for (Set<SessionWrapper> sessionInfoList : sessionCacheMap.values()) { wsList.addAll(sessionInfoList); } return wsList; }
From source file:com.github.drbookings.model.data.manager.MainManager.java
private void fillMissing() { final List<LocalDate> dates = new ArrayList<>(uiDataMap.keySet()); Collections.sort(dates);/*from w ww. java 2s.c om*/ final Collection<LocalDate> toAdd = new HashSet<>(); LocalDate last = null; for (final LocalDate d : dates) { if (last != null) { if (d.equals(last.plusDays(1))) { // ok } else { toAdd.addAll(new DateRange(last.plusDays(1), d.minusDays(1)).toList()); } } last = d; } for (final LocalDate d : toAdd) { addDateBean(new DateBean(d, this)); } }
From source file:de.csdev.ebus.cfg.std.EBusConfigurationReader.java
protected void parseTemplateConfiguration(EBusCollectionDTO collection) throws EBusConfigurationReaderException { // extract templates List<EBusCommandTemplatesDTO> templateSection = collection.getTemplates(); if (templateSection != null) { for (EBusCommandTemplatesDTO templates : templateSection) { List<EBusValueDTO> templateValues = templates.getTemplate(); if (templateValues != null) { Collection<EBusCommandValue> blockList = new ArrayList<EBusCommandValue>(); for (EBusValueDTO value : templateValues) { Collection<EBusCommandValue> pv = parseValueConfiguration(value, null, null); blockList.addAll(pv); // global id String id = collection.getId() + "." + templates.getName() + "." + value.getName(); logger.trace("Add template with global id {} to registry ...", id); templateValueRegistry.put(id, pv); }/*from w w w. ja v a 2 s .c o m*/ String id = collection.getId() + "." + templates.getName(); // global id logger.trace("Add template block with global id {} to registry ...", id); templateBlockRegistry.put(id, blockList); } } } }
From source file:org.openmrs.module.providermanagement.api.impl.ProviderSuggestionServiceImpl.java
@Override @Transactional(readOnly = true)/*from ww w.j a v a 2s. c o m*/ public List<Person> suggestProvidersForPatient(Patient patient, RelationshipType relationshipType) throws InvalidRelationshipTypeException, SuggestionEvaluationException { if (patient == null) { throw new APIException("Patient cannot be null"); } if (relationshipType == null) { throw new APIException("Relationship type cannot be null"); } if (!Context.getService(ProviderManagementService.class).getAllProviderRoleRelationshipTypes(false) .contains(relationshipType)) { throw new InvalidRelationshipTypeException("Invalid relationship type: " + relationshipType + " is not a valid provider relationship type"); } // first, see if there are any suggestion rules if not, just return null List<ProviderSuggestion> suggestions = getProviderSuggestionsByRelationshipType(relationshipType); if (suggestions == null || suggestions.size() == 0) { return null; } // otherwise, get all the providers that match the suggestion rules Collection<Person> suggestedProviders = new HashSet<Person>(); for (ProviderSuggestion suggestion : suggestions) { try { SuggestionEvaluator evaluator = suggestion.instantiateEvaluator(); Set<Person> p = evaluator.evaluate(suggestion, patient, relationshipType); if (p != null) { // note that we are doing union, not intersection, here if there are multiple rules suggestedProviders.addAll(p); } } catch (Exception e) { throw new SuggestionEvaluationException("Unable to evaluate suggestion " + suggestion, e); } } // only keep those providers that are valid (ie, support the specified relationship type // TODO: might want to test the performance of this suggestedProviders.retainAll(Context.getService(ProviderManagementService.class) .getProvidersAsPersonsByRelationshipType(relationshipType)); // finally, remove any providers that are already assigned to this patient suggestedProviders.removeAll(Context.getService(ProviderManagementService.class) .getProvidersAsPersonsForPatient(patient, relationshipType, new Date())); return new ArrayList<Person>(suggestedProviders); }
From source file:org.appverse.web.framework.backend.frontfacade.rest.authentication.JWSAuthenticationProvider.java
@Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { JWSAuthenticationToken authRequest = (JWSAuthenticationToken) authentication; String token = authRequest.getJwsToken(); Object messagePayload = authRequest.getPayload(); if (StringUtils.isEmpty(token)) throw new BadCredentialsException("Auth Token invalid"); try {//from w ww . j a v a 2s.c o m JWSObject jwsObject = JWSObject.parse(token); //We should test this comparation with binary payloads //Ensure message integrity if (!jwsObject.getPayload().toString().equals(messagePayload.toString())) { throw new BadCredentialsException("Invalid payload"); } if (jwsObject.verify(verifier)) { Collection<GrantedAuthority> authoritiesDefault = new ArrayList<GrantedAuthority>(); String[] roles = defaultRoles.split(","); for (String role : roles) { if (!StringUtils.isEmpty(role)) { GrantedAuthority auth = new SimpleGrantedAuthority(defaultRoles); authoritiesDefault.add(auth); } } if (userDetailsService != null) { UserDetails userDetails = userDetailsService.loadUserByUsername(cn); authoritiesDefault.addAll(userDetails.getAuthorities()); } JWSAuthenticationToken authResult = new JWSAuthenticationToken((Object) cn, authoritiesDefault); if (logger.isDebugEnabled()) { logger.debug("CN: " + cn); logger.debug("Authentication success: " + authResult); } return authResult; } } catch (ParseException pe) { throw new BadCredentialsException("Invalid JWS Object", pe); } catch (UsernameNotFoundException unfe) { throw new BadCredentialsException("Auth Token invalid", unfe); } catch (Exception e) { throw new BadCredentialsException("Unknown error", e); } return null; }
From source file:io.pcp.parfait.dxm.PcpMmvWriter.java
private Collection<Instance> getInstances() { Collection<Instance> instances = new ArrayList<Instance>(); for (InstanceDomain domain : instanceDomainStore.all()) { instances.addAll(domain.getInstances()); }//ww w . j av a2s . c om return instances; }
From source file:com.comcast.video.dawg.controller.park.ParkController.java
@SuppressWarnings("unchecked") @RequestMapping("/{token}*") public String userFront(@PathVariable String token, @RequestParam(required = false) String tag, @RequestParam(required = false) String q, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer size, @RequestParam(required = false) Boolean asc, @RequestParam(required = false) String[] sort, Model model, HttpSession session) throws CerealException { StringBuilder builder = new StringBuilder(); builder.append("Request=").append("token=").append(token).append(",q=").append(q).append(",tag=") .append(tag).append(",page=").append(page).append(",size=").append(size).append(",asc=").append(asc) .append(",sort=").append(sort); logger.info(builder.toString());/* www .j a v a 2s . com*/ if (isValid(token)) { token = clean(token); Map<String, Object>[] stbs = null; Map<String, Object>[] allDevices = null; Pageable pageable = null; if (null != sort) { if (0 == size) { size = 100; } Direction direction = asc ? Direction.ASC : Direction.DESC; Sort sorting = new Sort(direction, sort); pageable = new PageRequest(page, size, sorting); } if (null != tag) { if (null != q) { model.addAttribute("search", q); } stbs = service.findByCriteria(new TagCondition(tag, q).toCriteria(), pageable); } else if ((null != q) && (!q.trim().isEmpty())) { String[] keys = getKeys(q); stbs = service.findByKeys(keys, pageable); model.addAttribute("search", q); } else { Condition condition = (Condition) session.getAttribute("condition"); if (condition != null) { stbs = service.findByCriteria(condition.toCriteria(), pageable); session.removeAttribute("condition"); } else { stbs = service.findAll(pageable); model.addAttribute("search", ""); allDevices = stbs; } } Map<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("tag", tag); requestParams.put("q", q); requestParams.put("page", page); requestParams.put("size", size); requestParams.put("asc", asc); requestParams.put("sort", sort); String requestParamsJson = engine.writeToString(requestParams, Map.class); model.addAttribute("requestParams", requestParamsJson); Map<String, Object> devices = new HashMap<String, Object>(); Map<String, List<String>> deviceTags = new HashMap<String, List<String>>(); Object tagData = null; boolean anyReserved = false; for (Map<String, Object> stb : stbs) { if (stb.containsKey(MetaStb.MACADDRESS)) { String id = (String) stb.get(MetaStb.ID); devices.put(id, stb); tagData = stb.get(MetaStb.TAGS); if (tagData != null && (tagData instanceof List)) { deviceTags.put(id, (List<String>) tagData); } else { deviceTags.put(id, null); } String reserver = (String) stb.get(PersistableDevice.RESERVER); if ((token != null) && token.equals(reserver)) { anyReserved = true; } } } String deviceData = engine.writeToString(devices, Map.class); /** Get all the tags from other devices */ allDevices = allDevices == null ? service.findAll() : allDevices; Collection<String> otherTags = new HashSet<String>(); for (Map<String, Object> device : allDevices) { String id = (String) device.get(MetaStb.ID); if (!deviceTags.containsKey(id)) { tagData = device.get(MetaStb.TAGS); if (tagData != null && (tagData instanceof List)) { otherTags.addAll((List<String>) tagData); } } } model.addAttribute(LATEST_SEARCH_CONDITION_MODEL_ATTRIBUTE_NAME, returnAndRemoveLatestSearchCondition(session)); model.addAttribute(SEARCH_CONDITIONS_MODEL_ATTRIBUTE_NAME, getSearchConditions(session)); model.addAttribute("token", token); model.addAttribute("deviceData", deviceData); model.addAttribute("deviceTags", engine.writeToString(deviceTags)); model.addAttribute("otherTags", engine.writeToString(new ArrayList<String>(otherTags))); model.addAttribute("data", devices.values()); model.addAttribute("dawgShowUrl", config.getDawgShowUrl()); model.addAttribute("dawgPoundUrl", config.getDawgPoundUrl()); model.addAttribute("anyReserved", anyReserved); model.addAttribute("filterFields", SearchableField.values()); model.addAttribute("operators", Operator.values()); return "index"; } else { /** User login token is invalid, so redirects to login page */ return "login"; } }
From source file:net.sourceforge.fenixedu.dataTransferObject.inquiries.BlockResumeResult.java
private Collection<InquiryBlock> getAssociatedBlocks(InquiryResult inquiryResult) { Collection<InquiryBlock> associatedBlocks = inquiryResult.getInquiryQuestion().getAssociatedBlocksSet(); if (!inquiryResult.getInquiryQuestion().getAssociatedResultBlocksSet().isEmpty()) { associatedBlocks = new ArrayList<InquiryBlock>(); for (InquiryBlock inquiryBlock : inquiryResult.getInquiryQuestion().getAssociatedResultBlocksSet()) { for (InquiryGroupQuestion groupQuestion : inquiryBlock.getInquiryGroupsQuestionsSet()) { for (InquiryQuestion inquiryQuestion : groupQuestion.getInquiryQuestionsSet()) { associatedBlocks.addAll(inquiryQuestion.getAssociatedBlocksSet()); }/*from w ww . j a va 2s.c o m*/ } } } return associatedBlocks; }