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);
}
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;
}
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;
}
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;
}
}
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;
}
Aggregations