Search in sources :

Example 11 with MapEx

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

the class MavenRepository method getPom.

public MavenPom getPom(final String groupId, final String artifactId, final String version) {
    final String groupArtifactVersion = groupId + ":" + artifactId + ":" + version;
    MavenPom pom = this.pomCache.get(groupArtifactVersion);
    if (pom == null) {
        final Resource resource = getResource(groupId, artifactId, "pom", version);
        if (resource.exists()) {
            final MapEx map = Xml.toMap(resource);
            pom = new MavenPom(this, map);
            this.pomCache.put(groupArtifactVersion, pom);
        } else {
            return null;
        }
    }
    return pom;
}
Also used : MapEx(com.revolsys.collection.map.MapEx) PathResource(com.revolsys.spring.resource.PathResource) Resource(com.revolsys.spring.resource.Resource)

Example 12 with MapEx

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

the class RecordStoreConnection method toMapInternal.

protected MapEx toMapInternal() {
    final MapEx map = newTypeMap("recordStore");
    addAllToMap(map, getProperties());
    final String name = getName();
    map.put("name", name);
    final boolean savePassword = isSavePassword();
    map.put("savePassword", savePassword);
    return map;
}
Also used : MapEx(com.revolsys.collection.map.MapEx)

Example 13 with MapEx

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

the class CsvMapIterator method parseMap.

private MapEx parseMap(final List<String> record) {
    final MapEx map = new LinkedHashMapEx();
    for (int i = 0; i < this.fieldNames.size() && i < record.size(); i++) {
        final String fieldName = this.fieldNames.get(i);
        final String value = record.get(i);
        if (value != null) {
            map.put(fieldName, value);
        }
    }
    return map;
}
Also used : LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx)

Example 14 with MapEx

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

the class MapReaderRecordReader method next.

@Override
public Record next() {
    if (hasNext()) {
        final MapEx source = this.mapIterator.next();
        final Record target = new ArrayRecord(this.recordDefinition);
        for (final FieldDefinition field : this.recordDefinition.getFields()) {
            final String name = field.getName();
            final Object value = source.get(name);
            if (value != null) {
                final DataType dataType = this.recordDefinition.getFieldType(name);
                final Object convertedValue;
                try {
                    convertedValue = dataType.toObject(value);
                } catch (final Throwable e) {
                    throw new FieldValueInvalidException(name, value, e);
                }
                target.setValue(name, convertedValue);
            }
        }
        return target;
    } else {
        throw new NoSuchElementException();
    }
}
Also used : ArrayRecord(com.revolsys.record.ArrayRecord) FieldValueInvalidException(com.revolsys.record.FieldValueInvalidException) MapEx(com.revolsys.collection.map.MapEx) FieldDefinition(com.revolsys.record.schema.FieldDefinition) DataType(com.revolsys.datatype.DataType) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) NoSuchElementException(java.util.NoSuchElementException)

Example 15 with MapEx

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

the class RecordStoreConnectionRegistry method loadConnection.

@Override
protected RecordStoreConnection loadConnection(final Path connectionFile, final boolean importConnection) {
    final MapEx config = Json.toMap(connectionFile);
    final String name = getConnectionName(config, connectionFile, importConnection);
    try {
        @SuppressWarnings({ "unchecked", "rawtypes" }) final Map<String, Object> connectionProperties = Maps.get((Map) config, "connection", Collections.<String, Object>emptyMap());
        if (connectionProperties.isEmpty()) {
            Logs.error(this, "Record store must include a 'connection' map property: " + connectionFile);
            return null;
        } else {
            final RecordStoreConnection connection = new RecordStoreConnection(this, connectionFile.toString(), config);
            if (!importConnection) {
                connection.setConnectionFile(connectionFile);
            }
            addConnection(name, connection);
            return connection;
        }
    } catch (final Throwable e) {
        Logs.error(this, "Error creating record store from: " + connectionFile, e);
        return null;
    }
}
Also used : MapEx(com.revolsys.collection.map.MapEx)

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