Search in sources :

Example 6 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class DirectoryRecordStore method newIterator.

@Override
public AbstractIterator<Record> newIterator(final Query query, final Map<String, Object> properties) {
    final PathName path = query.getTypePath();
    final RecordReader reader = getRecords(path);
    reader.setProperties(properties);
    return new RecordReaderQueryIterator(reader, query);
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) PathName(com.revolsys.io.PathName)

Example 7 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class EsriXmlRecordDefinitionUtil method getRecordDefinition.

public static RecordDefinition getRecordDefinition(final String schemaName, final Domain domain, final boolean appendIdToName) {
    final String tableName;
    if (appendIdToName) {
        tableName = domain.getName() + "_ID";
    } else {
        tableName = domain.getName();
    }
    final PathName typePath = PathName.newPathName(PathUtil.toPath(schemaName, tableName));
    final RecordDefinitionImpl recordDefinition = new RecordDefinitionImpl(typePath);
    final FieldType fieldType = domain.getFieldType();
    final DataType dataType = EsriGeodatabaseXmlFieldTypeRegistry.INSTANCE.getDataType(fieldType);
    int length = 0;
    for (final CodedValue codedValue : domain.getCodedValues()) {
        length = Math.max(length, codedValue.getCode().toString().length());
    }
    recordDefinition.addField(tableName, dataType, length, true);
    recordDefinition.addField("DESCRIPTION", DataTypes.STRING, 255, true);
    recordDefinition.setIdFieldIndex(0);
    return recordDefinition;
}
Also used : RecordDefinitionImpl(com.revolsys.record.schema.RecordDefinitionImpl) DataType(com.revolsys.datatype.DataType) PathName(com.revolsys.io.PathName) FieldType(com.revolsys.record.io.format.esri.gdb.xml.model.enums.FieldType) EsriGeodatabaseXmlFieldType(com.revolsys.record.io.format.esri.gdb.xml.type.EsriGeodatabaseXmlFieldType)

Example 8 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class MapGuideWebService method getResources.

public Map<PathName, MapGuideResource> getResources(final String path) {
    final MapEx parameters = new LinkedHashMapEx();
    parameters.put("RESOURCEID", "Library:/" + path);
    parameters.put("COMPUTECHILDREN", "1");
    parameters.put("DEPTH", "-1");
    final MapEx response = getJsonResponse("ENUMERATERESOURCES", parameters);
    final MapEx resourceList = response.getValue("ResourceList");
    final List<MapEx> resourceFolders = resourceList.getValue("ResourceFolder");
    final Map<PathName, Folder> folderByPath = new HashMap<>();
    final Map<PathName, MapGuideResource> resourceByPath = new HashMap<>();
    for (final MapEx resourceDefinition : resourceFolders) {
        final Folder folder = new Folder(resourceDefinition);
        folder.setWebService(this);
        final PathName resourcePath = folder.getPath();
        folderByPath.put(resourcePath, folder);
        resourceByPath.put(resourcePath, folder);
        final PathName parentPath = resourcePath.getParent();
        if (parentPath != null) {
            final Folder parent = folderByPath.get(parentPath);
            parent.addResource(folder);
        }
    }
    final List<MapEx> resourceDocuments = resourceList.getValue("ResourceDocument");
    for (final MapEx resourceDefinition : resourceDocuments) {
        final List<String> resourceIdList = resourceDefinition.getValue("ResourceId");
        final String resourceId = resourceIdList.get(0);
        final String resourceType = resourceId.substring(resourceId.lastIndexOf(".") + 1);
        final Function<MapEx, ResourceDocument> factory = RESOURCE_DOCUMENT_FACTORIES.get(resourceType);
        if (factory != null) {
            final ResourceDocument resource = factory.apply(resourceDefinition);
            resource.setWebService(this);
            final PathName resourcePath = resource.getPath();
            resourceByPath.put(resourcePath, resource);
            final PathName parentPath = resourcePath.getParent();
            if (parentPath != null) {
                final Folder parent = folderByPath.get(parentPath);
                parent.addResource(resource);
            }
        } else {
            Logs.debug(this, "Unsupported resource type: " + resourceType);
        }
    }
    final Folder root = folderByPath.get(PathName.ROOT);
    if (root != null) {
        this.root = root;
    }
    return resourceByPath;
}
Also used : LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) HashMap(java.util.HashMap) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) PathName(com.revolsys.io.PathName)

Example 9 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class RecordStore method newRecord.

default Record newRecord(RecordDefinition recordDefinition, final Map<String, ? extends Object> values) {
    final PathName typePath = recordDefinition.getPathName();
    recordDefinition = getRecordDefinition(recordDefinition);
    if (recordDefinition == null) {
        throw new IllegalArgumentException("Cannot find table " + typePath + " for " + this);
    } else {
        final Record record = newRecord(recordDefinition);
        if (record != null) {
            record.setValues(values);
            final String idFieldName = recordDefinition.getIdFieldName();
            if (Property.hasValue(idFieldName)) {
                if (values.get(idFieldName) == null) {
                    final Identifier id = newPrimaryIdentifier(typePath);
                    record.setIdentifier(id);
                }
            }
        }
        return record;
    }
}
Also used : Identifier(com.revolsys.identifier.Identifier) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) PathName(com.revolsys.io.PathName)

Example 10 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class RecordStore method newRecordWithIdentifier.

default Record newRecordWithIdentifier(final RecordDefinition recordDefinition) {
    final Record record = newRecord(recordDefinition);
    if (record != null) {
        final String idFieldName = recordDefinition.getIdFieldName();
        if (Property.hasValue(idFieldName)) {
            final PathName typePath = recordDefinition.getPathName();
            final Identifier id = newPrimaryIdentifier(typePath);
            record.setIdentifier(id);
        }
    }
    return record;
}
Also used : Identifier(com.revolsys.identifier.Identifier) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) PathName(com.revolsys.io.PathName)

Aggregations

PathName (com.revolsys.io.PathName)64 FieldDefinition (com.revolsys.record.schema.FieldDefinition)15 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)14 DataType (com.revolsys.datatype.DataType)13 RecordDefinition (com.revolsys.record.schema.RecordDefinition)13 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)12 RecordStoreSchema (com.revolsys.record.schema.RecordStoreSchema)11 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)9 RecordStoreSchemaElement (com.revolsys.record.schema.RecordStoreSchemaElement)7 ArrayList (java.util.ArrayList)7 TreeMap (java.util.TreeMap)7 MapEx (com.revolsys.collection.map.MapEx)5 ResultSet (java.sql.ResultSet)5 Geodatabase (com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase)4 Identifier (com.revolsys.identifier.Identifier)4 JdbcConnection (com.revolsys.jdbc.JdbcConnection)4 Record (com.revolsys.record.Record)4 File (java.io.File)4 PreparedStatement (java.sql.PreparedStatement)4 Geometry (com.revolsys.geometry.model.Geometry)3