private Set<Project> getAssociatedProjectsFromClause( final User searcher, final TerminalClause clause) { final Set<Project> allVisibleProjects = new HashSet<Project>(permissionManager.getProjectObjects(Permissions.BROWSE, searcher)); Set<Project> associatedProjects = new HashSet<Project>(); final List<QueryLiteral> list = jqlOperandResolver.getValues(searcher, clause.getOperand(), clause); final Set<QueryLiteral> rawValues = list != null ? new LinkedHashSet<QueryLiteral>(list) : new LinkedHashSet<QueryLiteral>(); // if we are negating, we need to exclude projects with no category // e.g. category NOT IN ("cat1") is equivalent to category NOT IN ("cat1", EMPTY) if (isNegationOperator(clause.getOperator())) { rawValues.add(new QueryLiteral()); } for (QueryLiteral rawValue : rawValues) { final Collection<Project> projectsForCategory = projectCategoryResolver.getProjectsForCategory(rawValue); associatedProjects.addAll( CollectionUtils.intersection(allVisibleProjects, projectsForCategory)); } if (!associatedProjects.isEmpty()) { // if we have a negation operator we want every project context barr the associated ones. if (isNegationOperator(clause.getOperator())) { allVisibleProjects.removeAll(associatedProjects); associatedProjects = allVisibleProjects; } } return associatedProjects; }
public static Collection<DiffItem> intersection(Classes cl1, Classes cl2) { final List<DiffItem> diff = new ArrayList<DiffItem>(); for (Map.Entry<String, Collection<String>> entry1 : cl1.fileByArchive.entrySet()) { for (Map.Entry<String, Collection<String>> entry2 : cl2.fileByArchive.entrySet()) { Collection<String> v1 = entry1.getValue(); Collection<String> v2 = entry2.getValue(); Collection<String> inter = CollectionUtils.intersection(v1, v2); if (inter.size() == 0) { continue; } if (inter.size() == v1.size() && v1.size() == v2.size()) { diff.add(new SameItem(inter, entry1.getKey(), entry2.getKey())); } else if (inter.size() == v1.size()) { diff.add(new IncludedItem(inter, entry1.getKey(), entry2.getKey())); } else if (inter.size() == v2.size()) { diff.add(new ContainingItem(inter, entry1.getKey(), entry2.getKey())); } else { diff.add(new DiffItem(inter, entry1.getKey(), entry2.getKey())); } } } Collections.sort(diff, DiffItemComparator.getInstance()); return diff; }
/** {@inheritDoc} */ @Override protected Double measureSimilarity(ExtensionKey a, ExtensionKey b) { return Double.valueOf( CollectionUtils.intersection( Arrays.asList(a.queryStrings()), Arrays.asList(b.queryStrings())) .size() * 1024 - a.queryStrings().length); }
public CategoryOptionGroup getGroup(DataElementCategoryOptionCombo optionCombo) { Set<DataElementCategoryOption> categoryOptions = optionCombo.getCategoryOptions(); for (CategoryOptionGroup group : members) { if (!CollectionUtils.intersection(group.getMembers(), categoryOptions).isEmpty()) { return group; } } return null; }
public void characters(char[] ch, int start, int length) throws SAXException { if (placemarkactive && !CollectionUtils.intersection(visits, LEGALNAMES).isEmpty()) { if (currGeomHandler != null) { currGeomHandler.characters(ch, start, length); } else { String content = new String(ch, start, length).trim(); if (content.length() > 0) { lastEltData += content; // System.out.println(lastEltName + "= " + content); } } } }
public List<AdProblem> validateAd(Ad ad) { String title = ad.getTitle().trim(); String content = ad.getContent().trim(); Set<String> uncommonWords = Utils.getUncommonWords(title); uncommonWords.addAll(Utils.getUncommonWords(content)); List<AdProblem> problems = new ArrayList<AdProblem>(); if (uncommonWords.size() == 0) problems.add(AdProblem.allCommonWords); HashSet<String> vulgarities = Rater.getTheRater().getVulgarities(); Collection intersection = CollectionUtils.intersection(uncommonWords, vulgarities); if (intersection != null && intersection.size() > 0) problems.add(AdProblem.vulgarities); return problems; }
/** * SAX handler. Handle state and state transitions based on an element starting. * * @param uri Description of the Parameter * @param name Description of the Parameter * @param qName Description of the Parameter * @param atts Description of the Parameter * @exception SAXException Description of the Exception */ public void startElement(String uri, String name, String qName, Attributes atts) throws SAXException { if (name.equals("Placemark")) { placemarkactive = true; row = new GeoTiffResultRow(); // new row result; } visits.add(name); if (placemarkactive && !CollectionUtils.intersection(visits, LEGALNAMES).isEmpty()) { // if (name.equalsIgnoreCase(GMLConstants.GML_POLYGON) // || name.equalsIgnoreCase(GMLConstants.GML_POINT) // || name.equalsIgnoreCase(GMLConstants.GML_MULTI_GEOMETRY)) { if (name.equalsIgnoreCase(GMLConstants.GML_MULTI_GEOMETRY)) { currGeomHandler = new GMLHandler(fact, null); } if (currGeomHandler != null) currGeomHandler.startElement(uri, name, qName, atts); if (currGeomHandler == null) { lastEltName = name; // System.out.println(name); } } }
public Collection getAllIssueTypes() throws Exception { if (subTaskManager.isSubTasksEnabled()) { return constantsManager.getAllIssueTypeObjects(); } else { final ArrayList returnValues = new ArrayList(constantsManager.getRegularIssueTypeObjects()); // Now, since subtasks are disabled we want to make sure we add any subtask issue types that // are already // selected in the custom field and make sure that the sort order is the same as when we call // getAllIssueTypeObjects final List intersection = new ArrayList( CollectionUtils.intersection( constantsManager.getSubTaskIssueTypes(), getCustomField().getAssociatedIssueTypes())); Collections.sort(intersection); for (final Object anIntersection : intersection) { final GenericValue genericValue = (GenericValue) anIntersection; returnValues.add(0, constantsManager.getIssueTypeObject(genericValue.getString("id"))); } return returnValues; } }
/** * SAX handler - handle state information and transitions based on ending elements. * * @param uri Description of the Parameter * @param name Description of the Parameter * @param qName Description of the Parameter * @exception SAXException Description of the Exception */ @SuppressWarnings({"unused", "unchecked"}) public void endElement(String uri, String name, String qName) throws SAXException { // System.out.println("/" + name); // System.out.println("the ena name="+name); if (placemarkactive && !CollectionUtils.intersection(visits, LEGALNAMES).isEmpty() && currGeomHandler == null && !lastEltData.isEmpty()) { // System.out.println(lastEltName + " " + lastEltData); row.addPair(lastEltName, lastEltData); } lastEltData = ""; if (name.equals("Placemark")) { placemarkactive = false; try { row.addPair(GeoTiffReader2.this.primarykey, KeyGenerator.Generate()); } catch (Exception e) { e.printStackTrace(); System.exit(0); } GeoTiffReader2.this.results.add(row); } visits.remove(name); if (currGeomHandler != null) { currGeomHandler.endElement(uri, name, qName); if (currGeomHandler.isGeometryComplete()) { Geometry g = currGeomHandler.getGeometry(); WKTWriter wkt_writer = new WKTWriter(); GMLWriter gml_writer = new GMLWriter(); if (g.getClass().equals(com.vividsolutions.jts.geom.Point.class)) { Point geometry = (com.vividsolutions.jts.geom.Point) g; row.addPair("isEmpty", geometry.isEmpty()); row.addPair("isSimple", geometry.isSimple()); row.addPair("dimension", geometry.getCoordinates().length); row.addPair("coordinateDimension", geometry.getCoordinates().length); row.addPair("spatialDimension", geometry.getDimension()); // spatialdimension // <= // dimension // System.out.println(geometry.getCoordinate().x + " " // +geometry.getCoordinate().z); // System.out.println(geometry.get .getSRID()); // CRS. String crs = "2311"; if (crs == null) { System.err.println("No SRID specified. Aborting..."); System.exit(-1); } row.addPair( "asWKT", "<http://www.opengis.net/def/crs/EPSG/0/" + crs + ">" + wkt_writer.write(geometry)); row.addPair( "hasSerialization", "<http://www.opengis.net/def/crs/EPSG/0/" + crs + ">" + wkt_writer.write(geometry)); // newrow.addPair("hasSerialization", // wkt_writer.write(geometry)); gml_writer.setSrsName(crs); row.addPair("asGML", gml_writer.write(geometry).replaceAll("\n", " ")); row.addPair("is3D", geometry.getDimension() == 3); } else { GeometryCollection geometry = (GeometryCollection) g; row.addPair("isEmpty", geometry.isEmpty()); row.addPair("isSimple", geometry.isSimple()); row.addPair("dimension", geometry.getCoordinates().length); row.addPair("coordinateDimension", geometry.getCoordinates().length); row.addPair("spatialDimension", geometry.getDimension()); // spatialdimension // <= // dimension // System.out.println(geometry.getCoordinate().x + " " // +geometry.getCoordinate().z); // System.out.println(geometry.get .getSRID()); // CRS. String crs = "2323"; if (crs == null) { System.err.println("No SRID specified. Aborting..."); System.exit(-1); } // geometry.getNumPoints(); // TODO spatialDimension?????? // TODO coordinateDimension?????? // Geometry geometry1= // (Geometry)sourceGeometryAttribute.getValue(); // geometry1.transform(arg0, arg1) // sourceGeometryAttribute.ge row.addPair( "asWKT", "<http://www.opengis.net/def/crs/EPSG/0/" + crs + ">" + wkt_writer.write(geometry)); row.addPair( "hasSerialization", "<http://www.opengis.net/def/crs/EPSG/0/" + crs + ">" + wkt_writer.write(geometry)); // newrow.addPair("hasSerialization", // wkt_writer.write(geometry)); gml_writer.setSrsName("http://www.opengis.net/def/crs/EPSG/0/" + crs); row.addPair("asGML", gml_writer.write(geometry).replaceAll("\n", " ")); row.addPair("is3D", geometry.getDimension() == 3); } // System.out.println(g); // System.out.println(ww.write(g)); geoms.add(g); // reset to indicate no longer parsing geometry currGeomHandler = null; } } }
/* * (non-Javadoc) * @see es.gva.dgti.gvgeoportal.service.ogc.OGCInfoService * #getCapabilitiesFromWMS(String, String, String, boolean) */ public WMSInfo getCapabilitiesFromWMS( String urlServerWMS, TreeSet<String> listCrs, String format, boolean isCalledByWizard) throws ServerGeoException { WMSInfo wmsInfo = new WMSInfo(); // put url on object WMSInfo wmsInfo.setServiceUrl(urlServerWMS); // Create hashmap to add the layers getted to the WMSInfo object Map<String, org.gvsig.framework.web.ogc.WMSLayer> layersMap = new HashMap<String, org.gvsig.framework.web.ogc.WMSLayer>(); // Create conexion with server WMS try { WMSClient wms = new WMSClient(urlServerWMS); wms.connect(null); // set server information WMSServiceInformation serviceInfo = wms.getServiceInformation(); wmsInfo.setServiceAbstract(serviceInfo.abstr); wmsInfo.setServiceName(serviceInfo.name); wmsInfo.setServiceTitle(serviceInfo.title); // set id of the request wmsinfo (service name + calendar) int hashCode = (serviceInfo.name + Calendar.getInstance()).hashCode(); wmsInfo.setId(hashCode); // get and set version String version = wms.getVersion(); wmsInfo.setVersion(version); // get and set formats Vector formatVector = wms.getFormats(); TreeSet<String> formatSet = new TreeSet<String>(); formatSet.addAll(formatVector); wmsInfo.setFormatsSupported(formatSet); if (StringUtils.isEmpty(format)) { format = getFirstFormatSupported(formatSet); wmsInfo.setFormatSelected(format); } // check format if (isCalledByWizard || (!isCalledByWizard && formatVector.contains(format))) { wmsInfo.setFormatSelected(format); // get root layer WMSLayer rootLayer = wms.getRootLayer(); // get crs (srs) (belong to layer) Vector crsVector = rootLayer.getAllSrs(); // get and set all common crs supported TreeSet<String> crsTreeSet = new TreeSet<String>(); crsTreeSet.addAll(crsVector); wmsInfo.setCrsSupported(crsTreeSet); // Create tree with layer values List<TreeNode> tree = new ArrayList<TreeNode>(); // Create root node ArrayList<WMSLayer> children = rootLayer.getChildren(); TreeNode rootNode = new TreeNode("rootLayer_" + rootLayer.getName()); rootNode.setTitle(rootLayer.getTitle()); if (children.isEmpty()) { rootNode.setFolder(false); } else { rootNode.setFolder(true); rootNode.setExpanded(true); generateWMSChildrenNodes(children, tree, listCrs, rootNode, layersMap, wmsInfo); } // Set childrenLayers paramrootLayer.getChildren() wmsInfo.setChildrenCount(children.size()); // Only register the tree if it has a layer with crs defined if (rootNode.hasChildren()) { tree.add(rootNode); wmsInfo.setLayersTree(tree); } TreeSet<String> selCrs = new TreeSet<String>(); if (listCrs.isEmpty()) { selCrs.addAll(wmsInfo.getCrsSupported()); } else { selCrs.addAll(CollectionUtils.intersection(listCrs, wmsInfo.getCrsSupported())); } wmsInfo.setCrsSelected(selCrs); // Add map that contains info of all layers wmsInfo.setLayers(layersMap); } } catch (Exception exc) { // Show exception in log and create ServerGeoException which is // captured on controller and puts message to ajax response logger.error("Exception on getCapabilitiesFromWMS", exc); throw new ServerGeoException(); } return wmsInfo; }
private boolean hasProcessNecessaryStateTypes() { return !CollectionUtils.intersection( getAccessType().getAcceptedTypes(), getMainProcess().getAllPhdProcessStateTypes()) .isEmpty(); }
public Collection<String> findKnownKeys(Collection<String> coll) { if (valuesTrigger.size() == 1 && valuesTrigger.iterator().next().equals("*")) return coll; return CollectionUtils.intersection(valuesTrigger, coll); }