use of com.healthmarketscience.jackcess.Column in project pentaho-kettle by pentaho.
the class AccessInput method convert.
private Object convert(Object obj, AccessInputField field, int index) throws Exception {
// Get column
Column c = data.t.getColumn(field.getColumn());
// Find out field type
ValueMetaAndData sourceValueMetaAndData = AccessInputMeta.getValueMetaAndData(c, field.getName(), obj);
// DO CONVERSIONS...
//
ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta(data.totalpreviousfields + index);
return targetValueMeta.convertData(sourceValueMetaAndData.getValueMeta(), sourceValueMetaAndData.getValueData());
}
use of com.healthmarketscience.jackcess.Column in project tika by apache.
the class JackcessExtractor method parse.
public void parse(Database db, XHTMLContentHandler xhtml) throws IOException, SAXException, TikaException {
String pw = db.getDatabasePassword();
if (pw != null) {
parentMetadata.set(JackcessParser.MDB_PW, pw);
}
PropertyMap dbp = db.getDatabaseProperties();
for (PropertyMap.Property p : dbp) {
parentMetadata.add(JackcessParser.MDB_PROPERTY_PREFIX + p.getName(), toString(p.getValue(), p.getType()));
}
PropertyMap up = db.getUserDefinedProperties();
for (PropertyMap.Property p : up) {
parentMetadata.add(JackcessParser.USER_DEFINED_PROPERTY_PREFIX + p.getName(), toString(p.getValue(), p.getType()));
}
Set<String> found = new HashSet<>();
PropertyMap summaryProperties = db.getSummaryProperties();
if (summaryProperties != null) {
//try to get core properties
PropertyMap.Property title = summaryProperties.get(TITLE_PROP_KEY);
if (title != null) {
parentMetadata.set(TikaCoreProperties.TITLE, toString(title.getValue(), title.getType()));
found.add(title.getName());
}
PropertyMap.Property author = summaryProperties.get(AUTHOR_PROP_KEY);
if (author != null && author.getValue() != null) {
String authorString = toString(author.getValue(), author.getType());
SummaryExtractor.addMulti(parentMetadata, TikaCoreProperties.CREATOR, authorString);
found.add(author.getName());
}
PropertyMap.Property company = summaryProperties.get(COMPANY_PROP_KEY);
if (company != null) {
parentMetadata.set(OfficeOpenXMLExtended.COMPANY, toString(company.getValue(), company.getType()));
found.add(company.getName());
}
for (PropertyMap.Property p : db.getSummaryProperties()) {
if (!found.contains(p.getName())) {
parentMetadata.add(JackcessParser.SUMMARY_PROPERTY_PREFIX + p.getName(), toString(p.getValue(), p.getType()));
}
}
}
Iterator<Table> it = db.newIterable().setIncludeLinkedTables(false).setIncludeSystemTables(false).iterator();
while (it.hasNext()) {
Table table = it.next();
String tableName = table.getName();
List<? extends Column> columns = table.getColumns();
xhtml.startElement("table", "name", tableName);
addHeaders(columns, xhtml);
xhtml.startElement("tbody");
Row r = table.getNextRow();
while (r != null) {
xhtml.startElement("tr");
for (Column c : columns) {
handleCell(r, c, xhtml);
}
xhtml.endElement("tr");
r = table.getNextRow();
}
xhtml.endElement("tbody");
xhtml.endElement("table");
}
for (Query q : db.getQueries()) {
xhtml.startElement("div", "type", "sqlQuery");
xhtml.characters(q.toSQLString());
xhtml.endElement("div");
}
}
use of com.healthmarketscience.jackcess.Column in project tika by apache.
the class JackcessExtractor method addHeaders.
private void addHeaders(List<? extends Column> columns, XHTMLContentHandler xhtml) throws SAXException {
xhtml.startElement("thead");
xhtml.startElement("tr");
for (Column c : columns) {
xhtml.startElement("th");
xhtml.characters(c.getName());
xhtml.endElement("th");
}
xhtml.endElement("tr");
xhtml.endElement("thead");
}
use of com.healthmarketscience.jackcess.Column in project eol-globi-data by jhpoelen.
the class StudyImporterForADWTest method assertColumnNames.
private void assertColumnNames(List<String> expectedColumnNames, Table table) throws IOException {
Table links = table;
List<String> actualColumnNames = new ArrayList<String>();
List<? extends Column> columns = links.getColumns();
for (Column column : columns) {
actualColumnNames.add(column.getName());
}
assertThat(actualColumnNames, is(expectedColumnNames));
}
use of com.healthmarketscience.jackcess.Column in project pentaho-kettle by pentaho.
the class AccessOutputMeta method getColumns.
public static final List<Column> getColumns(RowMetaInterface row) {
List<Column> list = new ArrayList<Column>();
for (int i = 0; i < row.size(); i++) {
ValueMetaInterface value = row.getValueMeta(i);
Column column = new Column();
column.setName(value.getName());
int length = value.getLength();
switch(value.getType()) {
case ValueMetaInterface.TYPE_INTEGER:
if (length < 3) {
column.setType(DataType.BYTE);
length = DataType.BYTE.getFixedSize();
} else {
if (length < 5) {
column.setType(DataType.INT);
length = DataType.INT.getFixedSize();
} else {
column.setType(DataType.LONG);
length = DataType.LONG.getFixedSize();
}
}
break;
case ValueMetaInterface.TYPE_NUMBER:
column.setType(DataType.DOUBLE);
length = DataType.DOUBLE.getFixedSize();
break;
case ValueMetaInterface.TYPE_DATE:
column.setType(DataType.SHORT_DATE_TIME);
length = DataType.SHORT_DATE_TIME.getFixedSize();
break;
case ValueMetaInterface.TYPE_STRING:
if (length < 255) {
column.setType(DataType.TEXT);
length *= DataType.TEXT.getUnitSize();
} else {
column.setType(DataType.MEMO);
length *= DataType.MEMO.getUnitSize();
}
break;
case ValueMetaInterface.TYPE_BINARY:
column.setType(DataType.BINARY);
break;
case ValueMetaInterface.TYPE_BOOLEAN:
column.setType(DataType.BOOLEAN);
length = DataType.BOOLEAN.getFixedSize();
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
column.setType(DataType.NUMERIC);
length = DataType.NUMERIC.getFixedSize();
break;
default:
break;
}
if (length >= 0) {
column.setLength((short) length);
}
if (value.getPrecision() >= 1 && value.getPrecision() <= 28) {
column.setPrecision((byte) value.getPrecision());
}
list.add(column);
}
return list;
}
Aggregations