List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:dao.LineageDAO.java
public static List<String> getLiasDatasetNames(String abstractedObjectName) { if (StringUtils.isBlank(abstractedObjectName)) return null; List<String> totalNames = new ArrayList<String>(); totalNames.add(abstractedObjectName); List<String> mappedNames = getJdbcTemplate().queryForList(GET_MAPPED_OBJECT_NAME, String.class, abstractedObjectName);//from ww w.j a va2s . c om if (mappedNames != null && mappedNames.size() > 0) { totalNames.addAll(mappedNames); for (String name : mappedNames) { List<String> objNames = getJdbcTemplate().queryForList(GET_OBJECT_NAME_BY_MAPPED_NAME, String.class, name); { if (objNames != null) { totalNames.addAll(objNames); } } } } else { List<String> objNames = getJdbcTemplate().queryForList(GET_OBJECT_NAME_BY_MAPPED_NAME, String.class, abstractedObjectName); { if (objNames != null) { totalNames.addAll(objNames); } } } List<String> results = new ArrayList<String>(); Set<String> sets = new HashSet<String>(); sets.addAll(totalNames); results.addAll(sets); return results; }
From source file:net.sourceforge.fenixedu.domain.Professorship.java
public static List<Professorship> readByDegreeCurricularPlansAndExecutionYearAndBasic( List<DegreeCurricularPlan> degreeCurricularPlans, ExecutionYear executionYear, Boolean basic) { Set<Professorship> professorships = new HashSet<Professorship>(); for (DegreeCurricularPlan degreeCurricularPlan : degreeCurricularPlans) { for (CurricularCourse curricularCourse : degreeCurricularPlan.getCurricularCoursesSet()) { if (curricularCourse.getBasic() == null || curricularCourse.getBasic().equals(basic)) { if (executionYear != null) { for (ExecutionCourse executionCourse : curricularCourse .getExecutionCoursesByExecutionYear(executionYear)) { professorships.addAll(executionCourse.getProfessorshipsSet()); }// w ww . j a va 2 s . co m } else { for (ExecutionCourse executionCourse : curricularCourse .getAssociatedExecutionCoursesSet()) { professorships.addAll(executionCourse.getProfessorshipsSet()); } } } } } return new ArrayList<Professorship>(professorships); }
From source file:gov.jgi.meta.MetaUtils.java
public static Set<String> generateAllNeighborsAtDistance(String start, int distance) { Set<String> s = new HashSet<String>(); int[] v = new int[distance]; int i;/*from ww w . j a va 2 s. com*/ for (i = 0; i < distance; i++) v[i] = i; // init the change vector boolean overflow = false; while (!overflow) { Set<String> c = changeVectorApply(start, v); s.addAll(c); for (int j = v.length - 1; j >= 0; j--) { if (v[j] < start.length() - distance + j) { v[j] += 1; for (int k = j + 1; k < v.length; k++) v[k] = v[k - 1] + 1; break; } else if (j == 0) { v[j] = 0; overflow = true; } else { v[j] = 0; } } } return s; }
From source file:fr.inria.oak.paxquery.algebra.optimizer.rules.PushProjections.java
private static Set<ProjectColumn> deriveRequiredInputColumns(BaseLogicalOperator op, Set<ProjectColumn> columnsRequiredAbove) { final Set<ProjectColumn> requiredColumns = Sets.newTreeSet(); if (op instanceof XMLConstruct) { assert columnsRequiredAbove.isEmpty(); XMLConstruct xmlConstruct = (XMLConstruct) op; requiredColumns.addAll(deriveRequiredInputColumns(xmlConstruct.getApply(), xmlConstruct.getNRSMD())); } else if (op instanceof XMLTreeConstruct) { assert columnsRequiredAbove.isEmpty(); XMLTreeConstruct xmlConstruct = (XMLTreeConstruct) op; requiredColumns.addAll(deriveRequiredInputColumns(xmlConstruct.getConstructionTreePattern())); } else if (op instanceof LeftOuterNestedJoinWithAggregation) { // Nested outer join with aggregation LeftOuterNestedJoinWithAggregation lonja = (LeftOuterNestedJoinWithAggregation) op; Set<Integer> cols = PushdownUtility.getPredicateColumns(lonja.getPred()); for (int col : cols) { requiredColumns.add(new ProjectColumn(col)); }/*from w ww . j a va 2s .c om*/ if (lonja.getDocumentIDColumn() != -1) { requiredColumns.add(new ProjectColumn(lonja.getDocumentIDColumn())); } for (int col : lonja.getNodeIDColumns()) { requiredColumns.add(new ProjectColumn(col)); } requiredColumns.add(new ProjectColumn(lonja.getAggregationColumn())); final int leftNumberColumns = lonja.getNRSMD().getColNo() - 2; final int nestedField = leftNumberColumns; for (ProjectColumn column : columnsRequiredAbove) { if (column.pos < leftNumberColumns) { requiredColumns.add(column.copy()); } else if (column.pos == nestedField) { for (ProjectColumn nestedColumn : column.nestedColumns) { requiredColumns.add(nestedColumn.copy(leftNumberColumns + nestedColumn.pos)); } } } } else if (op instanceof LeftOuterNestedJoin) { // Nested outer join LeftOuterNestedJoin lonj = (LeftOuterNestedJoin) op; Set<Integer> cols = PushdownUtility.getPredicateColumns(lonj.getPred()); for (int col : cols) { requiredColumns.add(new ProjectColumn(col)); } if (lonj.getDocumentIDColumn() != -1) { requiredColumns.add(new ProjectColumn(lonj.getDocumentIDColumn())); } for (int col : lonj.getNodeIDColumns()) { requiredColumns.add(new ProjectColumn(col)); } final int leftNumberColumns = lonj.getNRSMD().getColNo() - 1; final int nestedField = leftNumberColumns; for (ProjectColumn column : columnsRequiredAbove) { if (column.pos < leftNumberColumns) { requiredColumns.add(column.copy()); } else if (column.pos == nestedField) { for (ProjectColumn nestedColumn : column.nestedColumns) { requiredColumns.add(nestedColumn.copy(leftNumberColumns + nestedColumn.pos)); } } } } else if (op instanceof BaseJoinOperator) { // Any other kind of join Set<Integer> cols = PushdownUtility.getPredicateColumns(((BaseJoinOperator) op).getPred()); for (int col : cols) { requiredColumns.add(new ProjectColumn(col)); } for (ProjectColumn column : columnsRequiredAbove) { requiredColumns.add(column.copy()); } } else if (op instanceof CartesianProduct) { // Cartesian product for (ProjectColumn column : columnsRequiredAbove) { requiredColumns.add(column.copy()); } } else if (op instanceof Aggregation) { // Aggregation Aggregation agg = (Aggregation) op; if (agg.getDocumentIDColumn() != -1) { requiredColumns.add(new ProjectColumn(agg.getDocumentIDColumn())); } requiredColumns.add(new ProjectColumn(agg.getAggregationPath()[0])); int limit; if (agg.getAggregationPath().length == 2) { limit = agg.getNRSMD().getColNo() - 1; } else if (agg.getAggregationPath().length == 1) { limit = 0; } else { limit = agg.getNRSMD().getColNo(); } for (ProjectColumn column : columnsRequiredAbove) { if (column.pos < limit) { requiredColumns.add(column.copy()); } } } else if (op instanceof GroupBy) { // Grouping GroupBy gb = (GroupBy) op; final boolean aggregate = gb instanceof GroupByWithAggregation; for (int pos : gb.getGroupByColumns()) { requiredColumns.add(new ProjectColumn(pos)); } for (int pos : gb.getReduceByColumns()) { requiredColumns.add(new ProjectColumn(pos)); } final int nestedColumnPos = aggregate ? op.getNRSMD().getColNo() - 2 : op.getNRSMD().getColNo() - 1; for (ProjectColumn column : columnsRequiredAbove) { if (column.pos == nestedColumnPos) { for (int i = 0; i < gb.getNestColumns().length; i++) { boolean added = false; for (ProjectColumn nested : column.nestedColumns) { if (nested.pos == i) { requiredColumns.add(nested.copy(gb.getNestColumns()[i])); added = true; break; } } if (!added) { requiredColumns.add(new ProjectColumn(i)); } } } } if (aggregate) { requiredColumns.add(new ProjectColumn(((GroupByWithAggregation) gb).getAggregationColumn())); } } else if (op instanceof Selection) { // Selection for (ProjectColumn column : columnsRequiredAbove) { requiredColumns.add(column.copy()); } Set<Integer> cols = PushdownUtility.getPredicateColumns(((Selection) op).getPred()); for (int col : cols) { requiredColumns.add(new ProjectColumn(col)); } } else if (op instanceof DuplicateElimination) { // DuplicateElimination for (ProjectColumn column : columnsRequiredAbove) { requiredColumns.add(column.copy()); } for (int col : ((DuplicateElimination) op).getColumns()) { requiredColumns.add(new ProjectColumn(col)); } } else if (op instanceof Navigation) { // Navigation Navigation pnop = (Navigation) op; // We add the column that we need for the navigation requiredColumns.add(new ProjectColumn(pnop.pos)); for (ProjectColumn column : columnsRequiredAbove) { if (column.pos < pnop.getChild().getNRSMD().getColNo() && column.pos != pnop.pos) { requiredColumns.add(column.copy()); } } } return requiredColumns; }
From source file:com.datatorrent.contrib.dimensions.DimensionsStoreHDHT.java
/** * clone a GPOMutable with selected field name * TODO: this class can move to the GPOUtils * @param fieldNames/*from w w w. j a v a 2s. c om*/ * @return */ public static GPOMutable cloneGPOMutableLimitToFields(GPOMutable orgGpo, Set<String> fieldNames) { Set<String> fieldsIncludeTime = Sets.newHashSet(); fieldsIncludeTime.addAll(fieldNames); fieldsIncludeTime.add("timeBucket"); fieldsIncludeTime.add("time"); return new GPOMutable(orgGpo, new Fields(fieldsIncludeTime)); }
From source file:models.PullRequest.java
private static ExpressionList<PullRequest> createSearchExpressionList(SearchCondition condition) { ExpressionList<PullRequest> el = finder.where(); if (condition.project != null) { el.eq(condition.category.project(), condition.project); }//from w w w .j av a2s. c om Expression state = createStateSearchExpression(condition.category.states()); if (state != null) { el.add(state); } if (condition.contributorId != null) { el.eq("contributor.id", condition.contributorId); } if (StringUtils.isNotBlank(condition.filter)) { Set<Object> ids = new HashSet<>(); ids.addAll(el.query().copy().where() .icontains("commentThreads.reviewComments.contents", condition.filter).findIds()); ids.addAll(el.query().copy().where().eq("pullRequestCommits.state", PullRequestCommit.State.CURRENT) .or(icontains("pullRequestCommits.commitMessage", condition.filter), icontains("pullRequestCommits.commitId", condition.filter)) .findIds()); Junction<PullRequest> junction = el.disjunction(); junction.icontains("title", condition.filter).icontains("body", condition.filter) .icontains("mergedCommitIdTo", condition.filter); if (!ids.isEmpty()) { junction.in("id", ids); } junction.endJunction(); } return el; }
From source file:com.example.app.support.address.AddressParser.java
private static String designatorConfusingCitiesCorrection(Map<AddressComponent, String> parsedLocation, String input) {// ww w.j a va2 s.com String street = parsedLocation.get(STREET); String type = parsedLocation.get(TYPE); String line2 = parsedLocation.get(LINE2); if (street == null || type == null || line2 != null || street.split(" ").length < 2) { return null; } Matcher m = STREET_DESIGNATOR_CHECK.matcher(street); if (m.find()) { String parsedstate = parsedLocation.get(STATE); if (parsedstate == null) { String parsedcity = parsedLocation.get(CITY); if (parsedcity != null && parsedcity.length() == 2) { parsedstate = parsedcity; } } String normalizedState = AddressStandardizer.normalizeState(StringUtils.upperCase(parsedstate)); String inputUpper = input.toUpperCase(); String ret = null; Set<String> stateSet = new HashSet<>(); if (normalizedState != null) { stateSet.add(normalizedState); } else { //if no state in put, this needs to work much harder stateSet.addAll(SpecialData.C_MAP.keySet()); } int stateIdx = parsedstate == null ? input.length() : input.lastIndexOf(parsedstate); for (String state : stateSet) { for (String s : SpecialData.C_MAP.get(state)) { int idx = -1; if ((idx = inputUpper.lastIndexOf(s)) != -1) { //and the input has one of the city names that can confuse the parser //this almost guaranteed to break the parser, help the parser by putting a comma separator before the city if (idx + s.length() >= stateIdx - 2) { return input.substring(0, idx) + ',' + input.substring(idx); } } } } return ret; } return null; }
From source file:com.nzion.util.UtilMisc.java
public static <T> Set<T> toSet(Collection<T> collection) { if (collection == null) return null; if (collection instanceof Set) { return (Set<T>) collection; } else {/*from w ww . j a v a 2s . c o m*/ Set<T> theSet = new HashSet<T>(); theSet.addAll(collection); return theSet; } }
From source file:io.fabric8.maven.core.util.kubernetes.KubernetesResourceUtil.java
public static Set<HasMetadata> loadResources(File manifest) throws IOException { Object dto = ResourceUtil.load(manifest, KubernetesResource.class); if (dto == null) { throw new IllegalStateException("Cannot load kubernetes manifest " + manifest); }// w w w .j a va 2 s.c om if (dto instanceof Template) { Template template = (Template) dto; dto = OpenshiftHelper.processTemplatesLocally(template, false); } Set<HasMetadata> entities = new TreeSet<>(new HasMetadataComparator()); entities.addAll(KubernetesHelper.toItemList(dto)); return entities; }
From source file:fi.hsl.parkandride.ActiveProfileAppender.java
@Override public String[] resolve(Class<?> testClass) { Set<String> profiles = currentActiveProfiles(); profiles.addAll(profilesToAppend); return profiles.toArray(new String[profiles.size()]); }