Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* DataCleaner (community edition)
* Copyright (C) 2014 Neopost - Customer Information Management
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.datacleaner.configuration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.xml.bind.JAXBElement;
import org.apache.metamodel.DataContext;
import org.apache.metamodel.MetaModelHelper;
import org.apache.metamodel.data.DataSet;
import org.apache.metamodel.data.Row;
import org.apache.metamodel.pojo.ArrayTableDataProvider;
import org.apache.metamodel.pojo.TableDataProvider;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.schema.ColumnTypeImpl;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
import org.apache.metamodel.util.CollectionUtils;
import org.apache.metamodel.util.SimpleTableDef;
import org.datacleaner.configuration.jaxb.AbstractDatastoreType;
import org.datacleaner.configuration.jaxb.PojoDatastoreType;
import org.datacleaner.configuration.jaxb.PojoTableType;
import org.datacleaner.configuration.jaxb.PojoTableType.Columns;
import org.datacleaner.configuration.jaxb.PojoTableType.Rows;
import org.datacleaner.connection.Datastore;
import org.datacleaner.connection.DatastoreConnection;
import org.datacleaner.connection.PojoDatastore;
import org.datacleaner.util.CollectionUtils2;
import org.datacleaner.util.ReflectionUtils;
import org.datacleaner.util.StringUtils;
import org.datacleaner.util.convert.StringConverter;
import org.datacleaner.util.xml.XmlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Convenient utility class for reading and writing POJO datastores from and to
* XML (JAXB) elements.
*/
public class JaxbPojoDatastoreAdaptor {
private static final Logger logger = LoggerFactory.getLogger(JaxbPojoDatastoreAdaptor.class);
private final StringConverter _converter;
/**
* @deprecated use the
* {@link #JaxbPojoDatastoreAdaptor(DataCleanerConfiguration)}
* constructor instead
*/
@Deprecated
public JaxbPojoDatastoreAdaptor() {
_converter = StringConverter.simpleInstance();
}
public JaxbPojoDatastoreAdaptor(final DataCleanerConfiguration configuration) {
_converter = new StringConverter(configuration);
}
public PojoDatastore read(final PojoDatastoreType pojoDatastore) {
final String name = pojoDatastore.getName();
final String schemaName = (pojoDatastore.getSchemaName() == null ? name : pojoDatastore.getSchemaName());
final List> tableDataProviders = new ArrayList<>();
final List tables = pojoDatastore.getTable();
for (final PojoTableType table : tables) {
final String tableName = table.getName();
final List columns = table.getColumns().getColumn();
final int columnCount = columns.size();
final String[] columnNames = new String[columnCount];
final ColumnType[] columnTypes = new ColumnType[columnCount];
for (int i = 0; i < columnCount; i++) {
final Columns.Column column = columns.get(i);
columnNames[i] = column.getName();
columnTypes[i] = ColumnTypeImpl.valueOf(column.getType());
}
final SimpleTableDef tableDef = new SimpleTableDef(tableName, columnNames, columnTypes);
final Collection