/** Traverses the expression and returns any encountered property names. */ public static String[] attributeNames(Expression expression) { return attributeNames(expression, null); }
/** Traverses the filter and returns any encountered property names. */ public static String[] attributeNames(Filter filter) { return attributeNames(filter, null); }
/** * Extracts List of attributes names from Filter * * @param filter * @return List of attributes names */ public static List<String> getAttributesOnFilter(Filter filter) { String[] attrs = DataUtilities.attributeNames(filter); return new ArrayList<String>(Arrays.asList(attrs)); }
/** * Compare if expression == propertyName * * @param expression * @param propertyName * @return */ public static boolean equalsPropertyExpression(Expression expression, String propertyName) { if (IndexQueryUtils.isExpressionEmpty(expression)) return false; String[] name = DataUtilities.attributeNames(expression); if (name.length != 1) return false; return Objects.equals(name[0], propertyName); }
public String[] getProperties() { if (properties == null) { List<String> propertiesList = new ArrayList<>(); // add the mapping attribute attributes String[] attributesProperties = DataUtilities.attributeNames(getTargetValue()); propertiesList.addAll(Arrays.asList(attributesProperties)); // add the target column propertiesList.add(targetColumn); // add the client properties for (Map.Entry<Name, Expression> entry : attributeMapping.getClientProperties().entrySet()) { String[] clientProperties = DataUtilities.attributeNames(entry.getValue()); propertiesList.addAll(Arrays.asList(clientProperties)); } // build the final properties array properties = propertiesList.toArray(new String[propertiesList.size()]); } return properties; }
/** * @param schemaDef * @param crs * @return */ public static SimpleFeatureType createFeatureType( String schemaName, String schemaDef, CoordinateReferenceSystem crs) { SimpleFeatureType indexSchema = null; if (schemaDef == null) { throw new IllegalArgumentException( "Unable to create feature type from null definition!"); } schemaDef = schemaDef.trim(); // get the schema try { indexSchema = DataUtilities.createType(schemaName, schemaDef); indexSchema = DataUtilities.createSubType( indexSchema, DataUtilities.attributeNames(indexSchema), crs); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); indexSchema = null; } return indexSchema; }
/** * Return a specific {@link FeatureTypeMapper} by parsing mapping properties contained within * the specified {@link Properties} object * * @param featureType * @return * @throws Exception */ protected FeatureTypeMapper getFeatureTypeMapper(final Properties props) throws Exception { SimpleFeatureType indexSchema; // Creating schema indexSchema = DataUtilities.createType(props.getProperty(NAME), props.getProperty(SCHEMA)); CoordinateReferenceSystem crs = CRS.parseWKT(props.getProperty(COORDINATE_REFERENCE_SYSTEM)); indexSchema = DataUtilities.createSubType( indexSchema, DataUtilities.attributeNames(indexSchema), crs); return getFeatureTypeMapper(indexSchema); }
/** Test for {@link DataUtilities#attributeNames(Expression, FeatureType)} */ public void testAttributeExpressionFilterFeatureType() { FilterFactory factory = CommonFactoryFinder.getFilterFactory(null); Expression expression = factory.add(factory.property("geom"), factory.property("gml:name")); String[] names; names = DataUtilities.attributeNames(expression, roadType); assertEquals(2, names.length); List namesList = Arrays.asList(names); assertTrue(namesList.contains("geom")); assertTrue(namesList.contains("name")); }
/** * Traverses the filter and returns any encountered property names. */ public static String[] attributeNames(Filter filter) { return attributeNames(filter, null); }
/** * Traverses the expression and returns any encountered property names. */ public static String[] attributeNames(Expression expression) { return attributeNames(expression, null); }
/** Test for {@link DataUtilities#attributeNames(FeatureType)} */ public void testAttributeNamesFeatureType() { String[] names; names = DataUtilities.attributeNames(roadType); assertEquals(4, names.length); assertEquals("id", names[0]); assertEquals("geom", names[1]); assertEquals("name", names[2]); assertEquals("uuid", names[3]); names = DataUtilities.attributeNames(subRoadType); assertEquals(2, names.length); assertEquals("id", names[0]); assertEquals("geom", names[1]); }
/** * Traverses the filter and returns any encoutered property names. * @deprecated use {@link #attributeNames(Filter, FeatureType)}/ */ public static String[] attributeNames(Filter filter) { return attributeNames( filter, null ); }
propertyNames = DataUtilities.attributeNames(featureType);
String[] attributeNames = DataUtilities.attributeNames(filter); for (String attrName : attributeNames) { if (attrName != null && !attrName.isEmpty() && !keys.containsField(attrName)) {
/** Test for {@link DataUtilities#attributeNames(Filter, FeatureType)} */ public void testAttributeNamesFilterFeatureType() { FilterFactory factory = CommonFactoryFinder.getFilterFactory(null); Filter filter = factory.equals( factory.property("id"), factory.add(factory.property("geom"), factory.property("gml:name"))); String[] names; names = DataUtilities.attributeNames(filter, roadType); assertEquals(3, names.length); List namesList = Arrays.asList(names); assertTrue(namesList.contains("id")); assertTrue(namesList.contains("geom")); assertTrue(namesList.contains("name")); }
names = DataUtilities.attributeNames(filter); assertEquals(names.length, 0); names = DataUtilities.attributeNames(fidFilter); assertEquals(0, names.length); names = DataUtilities.attributeNames(nullFilter); assertEquals(1, names.length); assertEquals("id", names[0]); names = DataUtilities.attributeNames(equal); assertEquals(2, names.length); List list = Arrays.asList(names); names = DataUtilities.attributeNames(fn); list = Arrays.asList(names); assertTrue(list.contains("name")); names = DataUtilities.attributeNames(between); assertEquals(3, names.length); list = Arrays.asList(names); names = DataUtilities.attributeNames(factory.and(geomNull, equal)); assertEquals(3, names.length); list = Arrays.asList(names); names = DataUtilities.attributeNames(factory.not(geomNull)); assertEquals(1, names.length); assertEquals("geom", names[0]);
indexSchema, DataUtilities.attributeNames(indexSchema), actualCRS); if (actualCRS != null) { Set<ReferenceIdentifier> identifiers = actualCRS.getIdentifiers();
private boolean usesProperty(final Filter filter) { final String[] attributes = DataUtilities.attributeNames(filter, type); // rely on best scene aggregation at a higher level if the filter is // using attributes not contained in the scene for (final String attr : attributes) { if (!ArrayUtils.contains(validPropertyNames, attr)) { return false; } } return true; } }
private boolean hasOtherProperties(final Filter cqlFilter) { final String[] attributes = DataUtilities.attributeNames(cqlFilter, type); for (final String attr : attributes) { if (!ArrayUtils.contains(SCENE_ATTRIBUTES, attr)) { return true; } } return false; }
private Set<String> requiredAttributes(Filter filter) { String[] filterAttributes = DataUtilities.attributeNames(filter); if (filterAttributes == null || filterAttributes.length == 0) { return Collections.emptySet(); } return Sets.newHashSet(filterAttributes); }