protected void initialize(MongoDBSession session) { if (dataFileName != null) { // fake schema for DirectoryCSVLoader.loadData SchemaImpl schema = new SchemaImpl(collection, null); schema.addField(sourceField, StringType.INSTANCE, null, 0, Collections.emptySet()); schema.addField(targetField, StringType.INSTANCE, null, 0, Collections.emptySet()); Consumer<Map<String, Object>> loader = map -> { Document doc = MongoDBSerializationHelper.fieldMapToBson(map); MongoCollection<Document> coll = getCollection(session); if (coll.countDocuments(doc) == 0) { coll.insertOne(doc); } }; DirectoryCSVLoader.loadData(dataFileName, BaseDirectoryDescriptor.DEFAULT_DATA_FILE_CHARACTER_SEPARATOR, schema, loader); } }
return null; Schema ecmSchema = new SchemaImpl(name, new Namespace(ns, prefix), isVersionWritable); if (singleComplexField.getType().isComplexType()) { ComplexType singleComplexFieldType = (ComplexType) singleComplexField.getType(); ecmSchema = new SchemaImpl(singleComplexFieldType, name, new Namespace(ns, prefix), isVersionWritable); } else {
/** * Create a schema from a ComplexType * * @since 5.7 * @param complexType * @param name * @param ns */ public SchemaImpl(ComplexType complexType, String name, Namespace ns, boolean isVersionWritabe) { super(null, SchemaNames.SCHEMAS, name, ns); this.isVersionWritabe = isVersionWritabe; if (complexType != null) { for (Field field : complexType.getFields()) { QName fieldname = QName.valueOf(field.getName().getLocalName(), ns.prefix); Type type = field.getType(); String defaultValue = type.encode(field.getDefaultValue()); Set<Constraint> constraint = field.getConstraints(); FieldImpl newField = new FieldImpl(fieldname, this, type, defaultValue, 0, constraint); newField.setConstant(field.isConstant()); addField(newField); } } }
if (loadData && dataFileName != null) { SchemaImpl schema = new SchemaImpl(tableName, null); schema.addField(sourceColumn, StringType.INSTANCE, null, 0, Collections.emptySet()); schema.addField(targetColumn, StringType.INSTANCE, null, 0, Collections.emptySet()); Insert insert = new Insert(table); for (Column column : table.getColumns()) {