/** * Override so asking for the hashCode does not implies traversing the whole map and thus * calling entrySet() prematurely */ @SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") public int hashCode() { return attributeName.hashCode(); }
public String getNamespace(Name name) { return name.getNamespaceURI() == null ? "" : name.getNamespaceURI(); }
public <T extends ResourceInfo> T getResourceByName(Name name, Class<T> clazz) { return getResourceByName(name.getNamespaceURI(), name.getLocalPart(), clazz); }
/** * Extracts the AttributeTypeInfo by copying them from the specified feature type. * * @param ft The schema to be harvested * @param info The optional feature type info from which all the attributes belong to */ public List<AttributeTypeInfo> getAttributes(FeatureType ft, FeatureTypeInfo info) { List<AttributeTypeInfo> attributes = new ArrayList<AttributeTypeInfo>(); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
/** * Delegates to {@link #getSchema(String)} with {@code name.getLocalPart()} * * @since 1.7 * @see DataAccess#getSchema(Name) */ public SimpleFeatureType getSchema(Name name) throws IOException { return getSchema(name.getLocalPart()); }
private Map<String, Object> buildDummyFeatureTypeInfo(ComplexAttribute f) { Map<String, Object> dummy = new HashMap<String, Object>(); dummy.put("name", f.getType().getName().getLocalPart()); dummy.put("namespace", getNamespace(f.getType().getName())); dummy.put("prefix", getPrefix(f.getType().getName())); dummy.put("title", "Layer: " + f.getType().getName().getLocalPart()); dummy.put("abstract", "[No Abstract Provided]"); dummy.put("description", "[No Description Provided]"); dummy.put("keywords", new ArrayList<String>()); dummy.put("metadataLinks", new ArrayList<String>()); dummy.put("SRS", "[SRS]"); if (f instanceof Feature) { final GeometryDescriptor gd = ((Feature) f).getType().getGeometryDescriptor(); if (gd != null) { dummy.put("nativeCRS", gd.getCoordinateReferenceSystem()); } } return dummy; }
/** * Notifies the caller the requested operation is not supported, using a plain {@link * UnsupportedOperationException} in case we have to conceal the fact the data is actually * writable, using an Spring security exception otherwise to force an authentication from the * user */ protected RuntimeException unsupportedOperation() { String typeName = getSchema().getName().getLocalPart(); if (policy.response == Response.CHALLENGE) { return SecureCatalogImpl.unauthorizedAccess(typeName); } else { return new UnsupportedOperationException(typeName + " is read only"); } } }
/** * Loads an attribute descriptor from feature type and attribute type metadata. * * <p>This method returns null if the attribute descriptor could not be loaded. */ public AttributeDescriptor getAttributeDescriptor( FeatureTypeInfo ftInfo, AttributeTypeInfo atInfo) throws Exception { FeatureType featureType = getFeatureType(ftInfo); if (featureType != null) { for (PropertyDescriptor pd : featureType.getDescriptors()) { if (pd instanceof AttributeDescriptor) { AttributeDescriptor ad = (AttributeDescriptor) pd; if (atInfo.getName().equals(ad.getLocalName())) { return ad; } } } } return null; }
public void modifyFeatures(AttributeDescriptor[] types, Object[] values, Filter filter) throws IOException { Name[] names = new Name[types.length]; for (int i = 0; i < types.length; i++) { names[i] = types[i].getName(); } modifyFeatures(names, values, filter); }
@Override public Function function(Name name, List<Expression> args, Literal fallback) { // Check if the name belongs to the IsInstanceOf NAME, otherwise null // is returned if (IsInstanceOf.NAME.getFunctionName().equals(name)) { return new IsInstanceOf(args, fallback); } return null; } }
public static CodeType code(Name name) { CodeType code = f.createCodeType(); // code.setCodeSpace(name.getNamespaceURI()); // code.setValue(name.getLocalPart()); code.setValue(name.getURI()); return code; }
public List<AttributeTypeInfo> loadAttributes(FeatureTypeInfo info) throws IOException { List<AttributeTypeInfo> attributes = new ArrayList(); FeatureType ft = getFeatureType(info); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
/** Delegates to {@link #removeSchema(String)} with {@code name.getLocalPart()} */ public void removeSchema(Name typeName) throws IOException { removeSchema(typeName.getLocalPart()); } }
public LayerInfo getLayerByName(Name name) { if (name.getNamespaceURI() != null) { NamespaceInfo ns = getNamespaceByURI(name.getNamespaceURI()); if (ns != null) { return getLayerByName(ns.getPrefix() + ":" + name.getLocalPart()); } } return getLayerByName(name.getLocalPart()); }
@Override public String prefixedName() { return featureSource.getName().getNamespaceURI() + ":" + getName(); }
/** * Delegates to {@link #getFeatureSource(String)} with {@code name.getLocalPart()} * * @since 2.5 * @see DataAccess#getFeatureSource(Name) */ public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException { return getFeatureSource(typeName.getLocalPart()); }
@Override public void dispose( FeatureTypeInfo info, DataAccess<? extends FeatureType, ? extends Feature> dataAccess, Name temporaryName) throws IOException { WFSDataStore wstore = (WFSDataStore) dataAccess; wstore.removeStoredQuery(temporaryName.getLocalPart()); } }
/** * Delegates to {@link #updateSchema(String, SimpleFeatureType)} with {@code * name.getLocalPart()} * * @since 1.7 * @see DataAccess#getFeatureSource(Name) */ public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException { updateSchema(typeName.getLocalPart(), featureType); }
@Override public void dispose( FeatureTypeInfo info, DataAccess<? extends FeatureType, ? extends Feature> dataAccess, Name temporaryName) throws IOException { JDBCDataStore ds = (JDBCDataStore) dataAccess; if (temporaryName != null) { ds.dropVirtualTable(temporaryName.getLocalPart()); } else { ds.dropVirtualTable(info.getNativeName()); } } }
public FeatureSourceWrappingFeatureTypeInfoImpl(FeatureSource featureSource) throws IOException, TransformException, FactoryException { super(); this.featureSource = featureSource; setName(featureSource.getName().getLocalPart()); setEnabled(true); setLatLonBoundingBox( featureSource.getBounds().transform(DefaultGeographicCRS.WGS84, true)); }