Search in sources :

Example 31 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class ArcGisRestCatalog method toMap.

@Override
public MapEx toMap() {
    final MapEx map = newTypeMap(J_TYPE);
    final String name = getName();
    addToMap(map, "name", name);
    map.put("serviceUrl", getServiceUrl());
    addToMap(map, "username", this.username, "");
    addToMap(map, "password", PasswordUtil.encrypt(this.password), "");
    return map;
}
Also used : MapEx(com.revolsys.collection.map.MapEx)

Example 32 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class ArcGisRestCatalog method initialize.

@Override
protected void initialize(final MapEx properties) {
    final List<CatalogElement> children = new ArrayList<>();
    final Map<String, CatalogElement> childByName = new HashMap<>();
    final List<String> folderNames = properties.getValue("folders", Collections.emptyList());
    for (final String folderPath : folderNames) {
        final String folderName = PathName.newPathName(folderPath).getName();
        final ArcGisRestCatalog folder = new ArcGisRestCatalog(this, folderName);
        children.add(folder);
        final String childKey = folderName.toLowerCase();
        childByName.put(childKey, folder);
    }
    final List<MapEx> serviceDescriptions = properties.getValue("services", Collections.emptyList());
    for (final MapEx serviceDescription : serviceDescriptions) {
        final String serviceContainerPath = serviceDescription.getString("name");
        final String serviceType = serviceDescription.getString("type");
        final String serviceContainerName = PathName.newPathName(serviceContainerPath).getName();
        try {
            final String childKey = serviceContainerName.toLowerCase();
            ArcGisRestServiceContainer container = (ArcGisRestServiceContainer) childByName.get(childKey);
            if (container == null) {
                container = new ArcGisRestServiceContainer(this, serviceContainerName);
                childByName.put(childKey, container);
                children.add(container);
            }
            ArcGisRestService service;
            final Function<ArcGisRestServiceContainer, ArcGisRestService> serviceFactory = SERVICE_FACTORY_BY_TYPE.get(serviceType);
            if (serviceFactory == null) {
                service = new ArcGisRestService(container, serviceType);
            } else {
                service = serviceFactory.apply(container);
            }
            container.addService(service);
        } catch (final Throwable e) {
            Logs.error(this, "Unable to get service: " + getServiceUrl() + "/" + serviceContainerPath, e);
        }
    }
    this.childByName = Collections.unmodifiableMap(childByName);
    this.children = Collections.unmodifiableList(children);
}
Also used : HashMap(java.util.HashMap) MapEx(com.revolsys.collection.map.MapEx) ArrayList(java.util.ArrayList)

Example 33 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class AnnotationLayer method initialize.

@Override
protected void initialize(final MapEx properties) {
    super.initialize(properties);
    final ArcGisRestAbstractLayerService service = getService();
    final Map<String, LayerDescription> layersByName = new TreeMap<>();
    final List<MapEx> layerDefinitions = properties.getValue("subLayers", Collections.emptyList());
    for (final MapEx layerProperties : layerDefinitions) {
        service.addLayer(this, layersByName, layerProperties);
    }
    this.layers = Lists.toArray(layersByName.values());
    this.layersByName = layersByName;
}
Also used : MapEx(com.revolsys.collection.map.MapEx) TreeMap(java.util.TreeMap)

Example 34 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class ArcGisRestAbstractLayerService method initChildren.

protected void initChildren(final MapEx properties, final List<CatalogElement> children, final Map<String, LayerDescription> rootLayersByName) {
    final Map<String, GroupLayer> groups = new TreeMap<>();
    final Map<String, LayerDescription> layers = new TreeMap<>();
    final List<MapEx> layerDefinitions = properties.getValue("layers", Collections.emptyList());
    for (final MapEx layerProperties : layerDefinitions) {
        final Integer parentLayerId = layerProperties.getInteger("parentLayerId");
        if (parentLayerId == null || parentLayerId == -1) {
            final LayerDescription layer = addLayer(this, rootLayersByName, layerProperties);
            if (layer != null) {
                final String layerName = layer.getName();
                if (layer instanceof GroupLayer) {
                    final GroupLayer group = (GroupLayer) layer;
                    groups.put(layerName, group);
                } else {
                    layers.put(layerName, layer);
                }
            }
        }
    }
    final List<MapEx> tableDefinitions = properties.getValue("tables", Collections.emptyList());
    for (final MapEx layerProperties : tableDefinitions) {
        final LayerDescription layer = addLayer(this, rootLayersByName, layerProperties);
        if (layer != null) {
            final String layerName = layer.getName();
            layers.put(layerName, layer);
        }
    }
    children.addAll(groups.values());
    children.addAll(layers.values());
}
Also used : MapEx(com.revolsys.collection.map.MapEx) TreeMap(java.util.TreeMap)

Example 35 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class FeatureLayer method setCodeTable.

@SuppressWarnings("unchecked")
private void setCodeTable(final FieldDefinition fieldDefinition, final MapEx field) {
    final MapEx domain = (MapEx) field.get("domain");
    if (domain != null) {
        final String domainType = domain.getString("type");
        final String domainName = domain.getString("name");
        final List<MapEx> codedValues = (List<MapEx>) domain.get("codedValues");
        if ("codedValue".equals(domainType) && Property.hasValuesAll(domainName, codedValues)) {
            final SimpleCodeTable codeTable = new SimpleCodeTable(domainName);
            for (final MapEx codedValue : codedValues) {
                final String code = codedValue.getString("code");
                final String description = codedValue.getString("name");
                codeTable.addValue(code, description);
            }
            fieldDefinition.setCodeTable(codeTable);
        }
    }
}
Also used : MapEx(com.revolsys.collection.map.MapEx) List(java.util.List) SimpleCodeTable(com.revolsys.record.code.SimpleCodeTable)

Aggregations

MapEx (com.revolsys.collection.map.MapEx)144 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)48 ArrayList (java.util.ArrayList)17 Resource (com.revolsys.spring.resource.Resource)9 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 Map (java.util.Map)7 HashMap (java.util.HashMap)6 PathName (com.revolsys.io.PathName)5 UrlResource (com.revolsys.spring.resource.UrlResource)5 DataType (com.revolsys.datatype.DataType)4 FieldDefinition (com.revolsys.record.schema.FieldDefinition)4 PathResource (com.revolsys.spring.resource.PathResource)4 Color (java.awt.Color)4 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)4 TreeMap (java.util.TreeMap)4 NamedLinkedHashMapEx (com.revolsys.collection.map.NamedLinkedHashMapEx)3 Geometry (com.revolsys.geometry.model.Geometry)3 LineString (com.revolsys.geometry.model.LineString)3 Record (com.revolsys.record.Record)3