List of usage examples for java.util List contains
boolean contains(Object o);
From source file:com.qubit.solution.fenixedu.integration.cgd.webservices.messages.member.SearchMemberOutputData.java
public static SearchMemberOutputData createDefault(IMemberIDAdapter strategy, Person person) { SearchMemberOutputData searchMemberOutputData = new SearchMemberOutputData(); searchMemberOutputData.setMemberID(strategy.retrieveMemberID(person)); searchMemberOutputData.setName(person.getName()); String socialSecurityNumber = person.getSocialSecurityNumber(); if (socialSecurityNumber != null && FiscalCodeValidation.isValidcontrib(socialSecurityNumber)) { searchMemberOutputData.setFiscalCode(Long.valueOf(socialSecurityNumber)); } else {/*from w w w. j ava2s .co m*/ searchMemberOutputData.setFiscalCode(0L); } Unit institutionUnit = Bennu.getInstance().getInstitutionUnit(); searchMemberOutputData.setEstablishmentName(institutionUnit.getName()); searchMemberOutputData.setEstablishmentCode(institutionUnit.getCode()); ExecutionYear readCurrentExecutionYear = ExecutionYear.readCurrentExecutionYear(); ExecutionYear previousYear = readCurrentExecutionYear.getPreviousExecutionYear(); List<ExecutionSemester> semesters = new ArrayList<ExecutionSemester>(); semesters.addAll(readCurrentExecutionYear.getExecutionPeriodsSet()); semesters.addAll(previousYear.getExecutionPeriodsSet()); String stayingIndicator = (person.getStudent() != null && person.getStudent().hasActiveRegistrations()) || (person.getTeacher() != null && person.getTeacher().getTeacherAuthorizationStream() .anyMatch(authorization -> semesters.contains(authorization.getExecutionSemester()))) ? "S" : "N"; searchMemberOutputData.setStayingIndicator(stayingIndicator); return searchMemberOutputData; }
From source file:com.aurel.track.screen.item.action.ScreenAction.java
/** * Prepares the replacement triggers/*from www .j a va 2s. c o m*/ * @param personID * @return */ public static List<TScreenBean> prepareReplacementScreens(List<Integer> screenIDs) { List<TScreenBean> replacementScreenList = ScreenDAOAdapter.getInstance().loadAll(); if (replacementScreenList != null && screenIDs != null) { Iterator<TScreenBean> iterator = replacementScreenList.iterator(); while (iterator.hasNext()) { TScreenBean screenBean = iterator.next(); if (screenIDs.contains(screenBean.getObjectID())) { iterator.remove(); } else { //taken the name as label screenBean.setLabel(screenBean.getName()); } } } return replacementScreenList; }
From source file:com.meltmedia.cadmium.servlets.BasicFileServlet.java
public static boolean validateStrong(String condition, String eTag) { List<String> parsed = parseETagList(condition); if (parsed.size() == 1 && "*".equals(parsed.get(0))) return true; else//from w w w.j a va 2 s . co m return parsed.contains(eTag); }
From source file:dsll.pinterest.crawler.Reduce.java
private static Text updatePinContent(String url, DBCollection pinsCollection) throws JSONException, IOException { // add more related pins, include more boards String id = url.split("/pin/")[1]; DBCursor c = pinsCollection.find(new BasicDBObject("ID", id)); DBObject oldPin = c.next();/*from w w w . j a v a 2 s . c o m*/ JSONArray oldBoards = new JSONArray(oldPin.get("board").toString()); JSONArray oldRltPin = new JSONArray(oldPin.get("related_pins").toString()); Document doc = Jsoup.connect(url).get(); Element bottomDoc = doc.select("div[class=Module CloseupSidebar]").first(); //pin board Element boardEle = bottomDoc.select("div[class=boardHeader]").first(); JSONArray board = new JSONArray(); JSONObject b = new JSONObject(); String boardName = ""; try { boardName = boardEle.select("h3[class=title]").text().trim(); } catch (Exception ee) { } String boardSrc = ""; try { boardSrc = "https://www.pinterest.com" + boardEle.select("a").attr("href").trim(); } catch (Exception ee) { } b.append("name", boardName); b.append("src", boardSrc); board.put(b); //related pins bottomDoc = doc .select("div[class=closeupBottom] div[class=Module CloseupBottom] div[class=relatedPinsWrapper]") .first(); JSONArray relatedPins = new JSONArray(); Elements relatedPinsConts = bottomDoc.select("div[class=pinWrapper]"); for (Element relatedPinsCont : relatedPinsConts) { JSONObject relatedPin = new JSONObject(); relatedPin.append("src", "https://www.pinterest.com" + relatedPinsCont.select("div[class=pinHolder] > a").attr("href")); relatedPins.put(relatedPin); } // process new boards List<String> oldBoardNames = new ArrayList<String>(); for (int i = 0; i < oldBoards.length(); i++) { oldBoardNames.add(oldBoards.getJSONObject(i).getString("name")); } for (int i = 0; i < board.length(); i++) { JSONObject tmp = board.getJSONObject(i); if (oldBoardNames.contains(tmp.getString("name"))) { continue; } oldBoards.put(board.get(i)); } // process new related pins List<String> oldRelatedPins = new ArrayList<String>(); for (int i = 0; i < oldRltPin.length(); i++) { oldRelatedPins.add(oldRltPin.getJSONObject(i).getString("src")); } for (int i = 0; i < relatedPins.length(); i++) { if (oldRelatedPins.contains(relatedPins.getJSONObject(i).get("src"))) { continue; } oldRltPin.put(relatedPins.getJSONObject(i)); } BasicDBObject newAttr = new BasicDBObject(); newAttr.append("board", oldBoards); newAttr.append("related_pins", oldRltPin); BasicDBObject update = new BasicDBObject().append("$set", newAttr); pinsCollection.update(new BasicDBObject("ID", id), update); return new Text("Pin " + id + " updated."); }
From source file:com.glaf.core.util.IdentityUtils.java
/** * ???//w w w .j a v a2s. c o m * * @param sqlSession * @param paramMap * @return */ public static List<String> getActorIds(SqlSession sqlSession, Map<String, Object> paramMap) { List<String> actorIds = new java.util.ArrayList<String>(); String statementId = CustomProperties.getString("sys.getActorIds"); if (StringUtils.isEmpty(statementId)) { statementId = "getActorIds"; } MyBatisEntityDAO entityDAO = new MyBatisEntityDAO(sqlSession); List<Object> rows = entityDAO.getList(statementId, paramMap); if (rows != null && !rows.isEmpty()) { for (Object object : rows) { if (object instanceof com.glaf.core.identity.User) { String actorId = ((com.glaf.core.identity.User) object).getActorId(); if (!actorIds.contains(actorId)) { actorIds.add(actorId); } } else if (object instanceof String) { String actorId = (String) object; if (!actorIds.contains(actorId)) { actorIds.add(actorId); } } } } return actorIds; }
From source file:org.openmrs.module.diagnosiscapturerwanda.util.DiagnosisUtil.java
/** * helper class to intersect two arrayLists * @param <T>//from w ww .j a v a2 s.c om * @param list1 * @param list2 * @return */ private static <T> List<T> intersection(List<T> list1, List<T> list2) { List<T> list = new ArrayList<T>(); for (T t : list1) { if (list2.contains(t)) { list.add(t); } } return list; }
From source file:com.wavemaker.commons.util.IOUtils.java
/** * Copy from: file to file, directory to directory, file to directory. * * @param source File object representing a file or directory to copy from. * @param destination File object representing the target; can only represent a file if the source is a file. * @param excludes A list of exclusion filenames. * @throws IOException/*from ww w. ja v a 2 s .c o m*/ */ public static void copy(File source, File destination, List<String> excludes) throws IOException { if (!source.exists()) { throw new IOException("Can't copy from non-existent file: " + source.getAbsolutePath()); } else if (excludes.contains(source.getName())) { return; } if (source.isDirectory()) { if (!destination.exists()) { FileUtils.forceMkdir(destination); } if (!destination.isDirectory()) { throw new IOException("Can't copy directory (" + source.getAbsolutePath() + ") to non-directory: " + destination.getAbsolutePath()); } File files[] = source.listFiles(new WMFileNameFilter()); for (int i = 0; i < files.length; i++) { copy(files[i], new File(destination, files[i].getName()), excludes); } } else if (source.isFile()) { if (destination.isDirectory()) { destination = new File(destination, source.getName()); } InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(destination); copy(in, out, true, true); } else { throw new IOException( "Don't know how to copy " + source.getAbsolutePath() + "; it's neither a directory nor a file"); } }
From source file:de.tor.tribes.util.VillageUtils.java
public static Village[] getVillagesByTag(Tag[] pTags, Tribe pTribe, RELATION pRelation, boolean pWithBarbarians, Comparator pComparator) { if (pTags == null) { return new Village[0]; }//from w w w. ja v a 2 s . co m List<Village> villages = new ArrayList<>(); HashMap<Village, Integer> usageCount = new HashMap<>(); for (Tag tag : pTags) { for (Integer id : tag.getVillageIDs()) { Village v = DataHolder.getSingleton().getVillagesById().get(id); if (pWithBarbarians || !v.getTribe().equals(Barbarians.getSingleton())) { if (pTribe == null || v.getTribe().getId() == pTribe.getId()) { usageCount.put(v, (usageCount.get(v) == null) ? 1 : usageCount.get(v) + 1); if (!villages.contains(v)) { villages.add(v); } } } } } if (pRelation.equals(RELATION.AND)) { //remove villages that are tagges by less tags than tagCount int tagAmount = pTags.length; for (Entry<Village, Integer> entry : usageCount.entrySet()) { if (entry.getValue() == null || entry.getValue() != tagAmount) { villages.remove(entry.getKey()); } } } if (pComparator != null) { Collections.sort(villages, pComparator); } return villages.toArray(new Village[villages.size()]); }
From source file:com.siberhus.web.ckeditor.utils.FileUtils.java
public static boolean isAllowed(String ext, String type) { String resourceType = type.toLowerCase(); if ("file".equals(resourceType)) { resourceType = "link"; }/* w w w . j ava 2 s.c o m*/ String fileExt = ext.toLowerCase(); CkeditorConfig.Upload config = CkeditorConfigurationHolder.config().upload(); List<String> allowedList = null;// config."${resourceType}".allowed List<String> deniedList = null;// config."${resourceType}".denied if ("link".equals(resourceType)) { allowedList = config.link().allowed(); deniedList = config.link().denied(); } else if ("image".equals(resourceType)) { allowedList = config.image().allowed(); deniedList = config.image().denied(); } else if ("flash".equals(resourceType)) { allowedList = config.flash().allowed(); deniedList = config.flash().denied(); } else { throw new IllegalArgumentException("Unkown resourceType: " + resourceType); } return ((allowedList.contains(fileExt) || allowedList.isEmpty()) && !(deniedList.contains(fileExt))); }
From source file:net.ontopia.topicmaps.nav2.portlets.pojos.MenuUtils.java
/** * Build the List of children of a given parent, from the topic map content. *//* www .j av a 2 s . co m*/ private static List buildChildren(TopicIF topic) { TopicMapIF tm = topic.getTopicMap(); ParsedQueryIF childrenQuery = MenuUtils.optimisticParse( "select $CHILD, $SORT from " + "menu:parent-child(%topic% : menu:parent, $CHILD : menu:child), " + "{ menu:sort($CHILD, $SORT) } order by $SORT?", tm); ParsedQueryIF headingsQuery = MenuUtils.optimisticParse( "select $CHILD from " + "menu:parent-child(%topic% : menu:parent, $CHILD : menu:child), " + "instance-of($CHILD, menu:heading)?", tm); List childrenTopics = MenuUtils.getResultValues(topic, childrenQuery); List headingsTopics = MenuUtils.getResultValues(topic, headingsQuery); // populate children List children = new ArrayList(childrenTopics.size()); for (int i = 0; i < childrenTopics.size(); i++) { TopicIF child = (TopicIF) childrenTopics.get(i); if (headingsTopics.contains(child)) children.add(buildHeading(child)); else children.add(buildItem(child)); } return children; }