当前位置: 首页>>代码示例>>Java>>正文


Java Column.getType方法代码示例

本文整理汇总了Java中org.apache.metamodel.schema.Column.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Column.getType方法的具体用法?Java Column.getType怎么用?Java Column.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.metamodel.schema.Column的用法示例。


在下文中一共展示了Column.getType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addColumn

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
private void addColumn(Column rawColumn, MTable mTable) {
    String columnName = rawColumn.getName();
    ColumnType columnType = rawColumn.getType();
    if (ColumnType.STRING.getName().equalsIgnoreCase(columnType.getName())) {
        columnType = ColumnTypeImpl.convertColumnType(Types.VARCHAR);
    }
    int jdbcType = columnType.getJdbcType();
    int typeInfo = -1;
    if (jdbcType == Types.VARCHAR) {
        Integer columnSize = rawColumn.getColumnSize();
        if (columnSize == null) {
            // FIXME: what is the proper length value?
            typeInfo = 128;
        } else {
            typeInfo = columnSize;
        }
    }

    LOG.debug("add column. columnName=" + columnName + ", jdbcType=" + jdbcType + ", typeInfo=" + typeInfo);
    MColumn mColumn = new MColumn(columnName, jdbcType, typeInfo, mTable);
    pm.makePersistent(mColumn);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:23,代码来源:JDOMetaContext.java

示例2: readSourceColumns

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
/**
 * Reads the source element of the job to extract a map of column IDs and
 * related source {@link InputColumn}s.
 *
 * @param sourceColumnMapping
 * @param analysisJobBuilder
 * @param source
 * @return
 */
private Map<String, InputColumn<?>> readSourceColumns(final SourceColumnMapping sourceColumnMapping,
        final AnalysisJobBuilder analysisJobBuilder, final SourceType source) {
    final Map<String, InputColumn<?>> inputColumns = new HashMap<>();
    final ColumnsType columnsType = source.getColumns();
    if (columnsType != null) {
        final List<ColumnType> columns = columnsType.getColumn();
        for (final ColumnType column : columns) {
            final String path = column.getPath();
            if (StringUtils.isNullOrEmpty(path)) {
                throw new IllegalStateException("Column path cannot be null");
            }
            final Column physicalColumn = sourceColumnMapping.getColumn(path);
            if (physicalColumn == null) {
                logger.error("Column {} not found in {}", path, sourceColumnMapping);
                throw new NoSuchColumnException(path);
            }

            final MetaModelInputColumn inputColumn = new MetaModelInputColumn(physicalColumn);
            final String id = column.getId();
            if (StringUtils.isNullOrEmpty(id)) {
                throw new IllegalStateException("Source column id cannot be null");
            }

            final String expectedType = column.getType();
            if (expectedType != null) {
                final org.apache.metamodel.schema.ColumnType actualType = physicalColumn.getType();
                if (actualType != null && !expectedType.equals(actualType.toString())) {
                    logger.warn("Column '{}' had type '{}', but '{}' was expected.",
                            new Object[] { path, actualType, expectedType });
                }
            }

            registerInputColumn(inputColumns, id, inputColumn);
            analysisJobBuilder.addSourceColumn(inputColumn);
        }
    }
    return inputColumns;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:48,代码来源:JaxbJobReader.java

示例3: createMetadata

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
public AnalysisJobMetadata createMetadata() {
    final MutableAnalysisJobMetadata mutableAnalysisJobMetadata = getAnalysisJobMetadata();

    final Datastore datastore = getDatastore();
    final String datastoreName = (datastore == null ? null : datastore.getName());

    final List<MetaModelInputColumn> sourceColumns = getSourceColumns();
    final List<String> sourceColumnPaths = new ArrayList<>(sourceColumns.size());
    final List<ColumnType> sourceColumnTypes = new ArrayList<>(sourceColumns.size());
    for (final MetaModelInputColumn sourceColumn : sourceColumns) {
        final Column column = sourceColumn.getPhysicalColumn();
        final String path = column.getQualifiedLabel();
        final ColumnType type = column.getType();

        sourceColumnPaths.add(path);
        sourceColumnTypes.add(type);
    }

    final Map<String, String> properties = mutableAnalysisJobMetadata.getProperties();
    final Map<String, String> variables = mutableAnalysisJobMetadata.getVariables();

    final String jobName = mutableAnalysisJobMetadata.getJobName();
    final String jobVersion = mutableAnalysisJobMetadata.getJobVersion();
    final String jobDescription = mutableAnalysisJobMetadata.getJobDescription();
    final String author = mutableAnalysisJobMetadata.getAuthor();
    final Date createdDate = mutableAnalysisJobMetadata.getCreatedDate();
    final Date updatedDate = mutableAnalysisJobMetadata.getUpdatedDate();

    return new ImmutableAnalysisJobMetadata(jobName, jobVersion, jobDescription, author, createdDate, updatedDate,
            datastoreName, sourceColumnPaths, sourceColumnTypes, variables, properties);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:32,代码来源:AnalysisJobBuilder.java

示例4: convertType

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
static Object convertType(final Object value, final Column targetColumn) throws IllegalArgumentException {
    if (value == null) {
        return null;
    }
    Object result = value;
    final ColumnType type = targetColumn.getType();
    if (type.isLiteral()) {
        // for strings, only convert some simple cases, since JDBC drivers
        // typically also do a decent job here (with eg. Clob types, char[]
        // types etc.)
        if (value instanceof Number || value instanceof Date) {
            result = value.toString();
        }
    } else if (type.isNumber()) {
        final Number numberValue = ConvertToNumberTransformer.transformValue(value);
        if (numberValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to number");
        }
        result = numberValue;
    } else if (type == ColumnType.BOOLEAN) {
        final Boolean booleanValue = ConvertToBooleanTransformer.transformValue(value);
        if (booleanValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to boolean");
        }
        result = booleanValue;
    }
    return result;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:29,代码来源:TypeConverter.java

示例5: createMetadata

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
public AnalysisJobMetadata createMetadata() {
    final MutableAnalysisJobMetadata mutableAnalysisJobMetadata = getAnalysisJobMetadata();

    final Datastore datastore = getDatastore();
    final String datastoreName = (datastore == null ? null : datastore.getName());

    final List<MetaModelInputColumn> sourceColumns = getSourceColumns();
    final List<String> sourceColumnPaths = new ArrayList<>(sourceColumns.size());
    final List<ColumnType> sourceColumnTypes = new ArrayList<>(sourceColumns.size());
    for (final MetaModelInputColumn sourceColumn : sourceColumns) {
        final Column column = sourceColumn.getPhysicalColumn();
        final String path = column.getQualifiedLabel();
        final ColumnType type = column.getType();

        sourceColumnPaths.add(path);
        sourceColumnTypes.add(type);
    }

    final Map<String, String> properties = mutableAnalysisJobMetadata.getProperties();
    final Map<String, String> variables = mutableAnalysisJobMetadata.getVariables();

    final String jobName = mutableAnalysisJobMetadata.getJobName();
    final String jobVersion = mutableAnalysisJobMetadata.getJobVersion();
    final String jobDescription = mutableAnalysisJobMetadata.getJobDescription();
    final String author = mutableAnalysisJobMetadata.getAuthor();
    final Date createdDate = mutableAnalysisJobMetadata.getCreatedDate();
    final Date updatedDate = mutableAnalysisJobMetadata.getUpdatedDate();

    final AnalysisJobMetadata metadata = new ImmutableAnalysisJobMetadata(jobName, jobVersion, jobDescription,
            author, createdDate, updatedDate, datastoreName, sourceColumnPaths, sourceColumnTypes, variables,
            properties);
    return metadata;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:34,代码来源:AnalysisJobBuilder.java

示例6: convertType

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
private Object convertType(final Object value, Column targetColumn) throws IllegalArgumentException {
    if (value == null) {
        return null;
    }
    Object result = value;
    ColumnType type = targetColumn.getType();
    if (type.isLiteral()) {
        // for strings, only convert some simple cases, since JDBC drivers
        // typically also do a decent job here (with eg. Clob types, char[]
        // types etc.)
        if (value instanceof Number || value instanceof Date) {
            result = value.toString();
        }
    } else if (type.isNumber()) {
        Number numberValue = ConvertToNumberTransformer.transformValue(value);
        if (numberValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to number");
        }
        result = numberValue;
    } else if (type == ColumnType.BOOLEAN) {
        Boolean booleanValue = ConvertToBooleanTransformer.transformValue(value);
        if (booleanValue == null && !"".equals(value)) {
            throw new IllegalArgumentException("Could not convert " + value + " to boolean");
        }
        result = booleanValue;
    }
    return result;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:29,代码来源:InsertIntoTableAnalyzer.java

示例7: configureJobType

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
private void configureJobType(final AnalysisJob analysisJob, final JobType jobType,
        final BiMap<InputColumn<?>, String> columnMappings, final boolean includeMetadata) {
    if (includeMetadata) {
        try {
            final JobMetadataType jobMetadata = _jobMetadataFactory.create(analysisJob);
            jobType.setJobMetadata(jobMetadata);
        } catch (final Exception e) {
            logger.warn("Exception occurred while creating job metadata", e);
        }
    }

    final VariablesType variablesType = new VariablesType();
    final Map<String, String> variables = analysisJob.getMetadata().getVariables();
    if ((variables != null) && (variables.size() > 0)) {
        for (final Map.Entry<String, String> variableEntry : variables.entrySet()) {
            final VariableType variableType = new VariableType();
            variableType.setId(variableEntry.getKey());
            variableType.setValue(variableEntry.getValue());
            variablesType.getVariable().add(variableType);
        }
    }

    final SourceType sourceType = new SourceType();
    sourceType.setColumns(new ColumnsType());
    if ((variables != null) && (variables.size() > 0)) {
        sourceType.setVariables(variablesType);
    }
    jobType.setSource(sourceType);

    final Datastore datastore = analysisJob.getDatastore();
    if (!(datastore instanceof OutputDataStreamDatastore)) {
        final DataContextType dataContextType = new DataContextType();
        if (datastore == null) {
            logger.warn("No datastore specified for analysis job: {}", analysisJob);
        } else {
            dataContextType.setRef(datastore.getName());
        }
        sourceType.setDataContext(dataContextType);
    }

    final Map<FilterOutcome, String> outcomeMappings = new LinkedHashMap<>();

    // mappings for lookup of component's elements
    final Map<TransformerJob, TransformerType> transformerMappings = new LinkedHashMap<>();
    final Map<FilterJob, FilterType> filterMappings = new LinkedHashMap<>();
    final Map<AnalyzerJob, AnalyzerType> analyzerMappings = new LinkedHashMap<>();

    // register all source columns
    final Collection<InputColumn<?>> sourceColumns = analysisJob.getSourceColumns();
    final String columnPathQualification = getColumnPathQualification(datastore, sourceColumns);
    for (final InputColumn<?> inputColumn : sourceColumns) {
        final ColumnType jaxbColumn = new ColumnType();
        final Column physicalColumn = inputColumn.getPhysicalColumn();
        jaxbColumn.setPath(getColumnPath(physicalColumn, columnPathQualification));
        jaxbColumn.setId(getColumnId(inputColumn, columnMappings));

        final org.apache.metamodel.schema.ColumnType columnType = physicalColumn.getType();
        if (columnType != null) {
            jaxbColumn.setType(columnType.toString());
        }

        sourceType.getColumns().getColumn().add(jaxbColumn);
    }

    // adds all components to the job and their corresponding mappings
    addComponents(jobType, analysisJob, columnMappings, transformerMappings, filterMappings, analyzerMappings);

    // add all transformed columns to their originating components and the
    // mappings
    addTransformedColumns(columnMappings, transformerMappings);

    // register all requirements
    addRequirements(outcomeMappings, transformerMappings, filterMappings, analyzerMappings, columnMappings);

    addConfiguration(analysisJob, transformerMappings, filterMappings, analyzerMappings, columnMappings);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:77,代码来源:JaxbJobWriter.java

示例8: testQuery

import org.apache.metamodel.schema.Column; //导入方法依赖的package包/类
public void testQuery() throws Exception {
	Schema schema = dc.getSchemaByName("METER.DBF");
	Table table = schema.getTableByName("METER");

	List<Column> columns = table.getColumns();
	Query q = new Query().select(columns).from(table);
	assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(0)
			.getColumn().getType());
	assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(6)
			.getColumn().getType());
	assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(7)
			.getColumn().getType());
	assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(8)
			.getColumn().getType());
	assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(9)
			.getColumn().getType());
	assertEquals(ColumnType.DOUBLE, q.getSelectClause().getItem(30)
			.getColumn().getType());
	DataSet ds = dc.executeQuery(q);

	assertTrue(ds.next());

	// create a cross-locale string comparison of the date field
	final String dateString;
	{
		Date date = DateUtils.get(2009, Month.AUGUST, 31);
		dateString = date.toString();
	}

	assertEquals(
			"Row[values=[0002, 0001, 0001, 0001, 0001, 0001, 21, 2008,   -1, N, C, A, 0, 149627, A, "
					+ dateString
					+ ", E, NRC E1                , Electric  , Cost      , $             ,               , SimActual             , Parkwood Hospital     , Parkwood Hospital     , Neuro Rehab Centre    , 2893.26, 2180.46, 4541.75, 2894.24, 2981.31, 2702.11, 2733.67, 2733.67, 2597.37, 2850.39, 2914.74, 2951.58, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 12.0]]",
			ds.getRow().toString());
	assertEquals(Double.class, ds.getRow().getValue(30).getClass());

	while (ds.next()) {
		Row row = ds.getRow();
		List<SelectItem> selectItems = row.getSelectItems();
		for (int i = 0; i < selectItems.size(); i++) {
			SelectItem selectItem = selectItems.get(i);
			Column column = columns.get(i);
			assertSame(selectItem.getColumn(), column);

			Object selectItemValue = row.getValue(selectItem);
			Object columnValue = row.getValue(column);
			assertEquals(selectItemValue, columnValue);

			assertNotNull(columnValue);

			if (column.getType() == ColumnType.CHAR) {
				assertTrue(columnValue instanceof Character
						|| columnValue instanceof String);
			} else if (column.getType() == ColumnType.FLOAT) {
				assertTrue(columnValue instanceof Float);
			} else if (column.getType() == ColumnType.DOUBLE) {
				assertTrue(columnValue instanceof Double);
			} else if (column.getType() == ColumnType.DATE) {
				assertTrue(columnValue instanceof Date);
			} else if (column.getType() == ColumnType.OTHER) {
				System.out.println("other type: " + columnValue);
			} else {
				throw new MetaModelException(
						"Value type not expected for Dbase data: " + column);
			}
		}
	}
	ds.close();
}
 
开发者ID:datacleaner,项目名称:metamodel_extras,代码行数:70,代码来源:DbaseDataContextMeterTest.java


注:本文中的org.apache.metamodel.schema.Column.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。