Search in sources :

Example 1 with RecordDefinitionFactory

use of com.revolsys.record.schema.RecordDefinitionFactory in project com.revolsys.open by revolsys.

the class SaifReader method loadExportedObjects.

/**
 * Load the exported objects for the SAIF archive.
 *
 * @throws IOException If there was an I/O error.
 */
@SuppressWarnings("unchecked")
private void loadExportedObjects() throws IOException {
    final boolean setNames = this.includeTypeNames.isEmpty();
    final ClassPathResource resource = new ClassPathResource("com/revolsys/io/saif/saifzip.csn");
    final RecordDefinitionFactory schema = new SaifSchemaReader().loadSchema(resource);
    final OsnReader reader = getOsnReader(schema, this.factory, "/exports.dir");
    try {
        final Map<String, String> names = new TreeMap<>();
        if (reader.hasNext()) {
            this.exportedObjects = reader.next();
            final Set<Record> handles = (Set<Record>) this.exportedObjects.getValue("handles");
            for (final Record exportedObject : handles) {
                final String fileName = (String) exportedObject.getValue("objectSubset");
                if (fileName != null && !fileName.equals("globmeta.osn")) {
                    String typePath = getTypeName(fileName);
                    if (typePath == null) {
                        final String name = (String) exportedObject.getValue("type");
                        typePath = PathCache.getName(name);
                        if (!this.fileNameTypeNameMap.containsKey(fileName)) {
                            this.fileNameTypeNameMap.put(fileName, typePath);
                            this.typePathFileNameMap.put(typePath, fileName);
                        }
                    }
                    if (setNames && !fileName.equals("metdat00.osn") && !fileName.equals("refsys00.osn")) {
                        names.put(typePath.toString(), typePath);
                    }
                }
            }
            if (setNames) {
                this.typePaths = new ArrayList<>(names.values());
            } else {
                this.typePaths = new ArrayList<>(this.includeTypeNames);
            }
            this.typePaths.removeAll(this.excludeTypeNames);
        }
    } finally {
        reader.close();
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) RecordDefinitionFactory(com.revolsys.record.schema.RecordDefinitionFactory) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) TreeMap(java.util.TreeMap) ClassPathResource(com.revolsys.spring.resource.ClassPathResource)

Aggregations

ArrayRecord (com.revolsys.record.ArrayRecord)1 Record (com.revolsys.record.Record)1 RecordDefinitionFactory (com.revolsys.record.schema.RecordDefinitionFactory)1 ClassPathResource (com.revolsys.spring.resource.ClassPathResource)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1