if (c.getType().equals(DataType.OLE)) { handleOLE(r, c.getName(), handler); } else if (c.getType().equals(DataType.BINARY)) { Object obj = r.get(c.getName()); if (obj != null) { byte[] bytes = (byte[])obj; Object obj = r.get(c.getName()); String v = toString(obj, c.getType()); if (isRichText(c)) { BodyContentHandler h = new BodyContentHandler();
DataType type = c.getType(); sourceValueMeta = ValueMetaFactory.createValueMeta( name == null ? c.getName() : name, sourceValueType ); } catch ( KettlePluginException e ) { sourceValueMeta = new ValueMetaNone( name == null ? c.getName() : name ); sourceValueMeta.setLength( c.getLength(), c.getPrecision() );
private boolean isRichText(Column c) throws IOException { if (c == null) { return false; } PropertyMap m = c.getProperties(); if (m == null) { return false; } if (c.getType() == null || ! c.getType().equals(DataType.MEMO)) { return false; } Object b = m.getValue(TEXT_FORMAT_KEY); if (b instanceof Byte) { if (((Byte)b).byteValue() == RICH_TEXT_FORMAT) { return true; } } return false; }
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"); }
@Override protected Schema getMainSchema() throws MetaModelException { Schema schema = new Schema(_file.getName()); Database db = getDatabase(); for (com.healthmarketscience.jackcess.Table mdbTable : db) { Table table = new Table(mdbTable.getName(), TableType.TABLE, schema); try { int i = 0; for (com.healthmarketscience.jackcess.Column mdbColumn : mdbTable .getColumns()) { ColumnType columnType = ColumnType .convertColumnType(mdbColumn.getSQLType()); Column column = new Column(mdbColumn.getName(), columnType, table, i, null); column.setColumnSize((int) mdbColumn.getLength()); column.setNativeType(mdbColumn.getType().name()); table.addColumn(column); i++; } schema.addTable(table); } catch (Exception e) { throw new MetaModelException(e); } } return schema; }
/** * Sets all attributes except name from the given Column template (including * all column properties except GUID). */ public ColumnBuilder setFromColumn(Column template) throws IOException { DataType type = template.getType(); setType(type); setLength(template.getLength()); setAutoNumber(template.isAutoNumber()); if(type.getHasScalePrecision()) { setScale(template.getScale()); setPrecision(template.getPrecision()); } setCalculated(template.isCalculated()); setCompressedUnicode(template.isCompressedUnicode()); setHyperlink(template.isHyperlink()); if(template instanceof ColumnImpl) { setTextSortOrder(((ColumnImpl)template).getTextSortOrder()); } PropertyMap colProps = template.getProperties(); for(PropertyMap.Property colProp : colProps) { // copy everything but guid if(!PropertyMap.GUID_PROP.equalsIgnoreCase(colProp.getName())) { setProperty(colProp.getName(), colProp); } } return this; }
private void setDefaultValue(Column cl, String ntn, List<String> arTrigger) throws IOException, SQLException { PropertyMap pm = cl.getProperties(); String ncn = procedureEscapingIdentifier(cl.getName()); Object defaulT = pm.getValue(PropertyMap.DEFAULT_VALUE_PROP); if (defaulT != null) { String default4SQL = defaultValue4SQL(defaulT, cl.getType()); String guidExp = "GenGUID()"; if (!guidExp.equals(defaulT)) { defaulT.toString().trim().endsWith(")") && defaulT.toString().indexOf("(") > 0; if (defaultIsFunction) { metadata.columnDef(cl.getTable().getName(), cl.getName(), defaulT.toString()); if (!isNull && (defFound = tryDefault(default4SQL)) == null) { Logger.logParametricWarning(Messages.UNKNOWN_EXPRESSION, "" + defaulT, cl.getName(), cl.getTable().getName()); } else { if (defFound != null && !defaultIsFunction) { metadata.columnDef(cl.getTable().getName(), cl.getName(), defFound.toString()); if (cl.getType() == DataType.TEXT && defaulT.toString().startsWith("'") && defaulT.toString().endsWith("'") && defaulT.toString().length() > cl.getLengthInUnits()) { Logger.logParametricWarning(Messages.DEFAULT_VALUES_DELIMETERS, "" + defaulT, cl.getName(), cl.getTable().getName(), "" + cl.getLengthInUnits());
String comma = ""; for (Column cl : lc) { if ("USER".equalsIgnoreCase(cl.getName())) { Logger.logParametricWarning(Messages.USER_AS_COLUMNNAME, t.getName()); String cn = SQLConverter.preEscapingIdentifier(cl.getName()); String ctype = cl.getType().name(); if (cl.isAutoNumber()) { ColumnImpl cli = (ColumnImpl) cl; AutoNumberGenerator ang = cli.getAutoNumberGenerator(); } else if (cl.isHyperlink()) { ctype = "HYPERLINK"; metadata.newColumn(cl.getName(), cn, ctype, seq); if (expr != null && constraints) { metadata.calculatedField(t.getName(), cl.getName()); sbC.append(comma).append(cn).append(" ").append(htype); PropertyMap pm = cl.getProperties(); Object required = pm.getValue(PropertyMap.REQUIRED_PROP); if (constraints && required != null && required instanceof Boolean && ((Boolean) required)) {
@Override public Object handleRowError(Column cl, byte[] bt, Location location, Exception ex) throws IOException { if (cl.getType().isTextual()) { Logger.logParametricWarning(Messages.INVALID_CHARACTER_SEQUENCE, cl.getTable().getName(), cl.getName(), new String(bt)); } throw new IOException(ex.getMessage()); } });
PreparedStatement ps = null; for (Column cl : _table.getColumns()) { if (cl.isAutoNumber()) { UcanaccessConnection conn = UcanaccessConnection.getCtxConnection(); Connection connHsqldb = conn.getHSQLDBConnection(); String cn = SQLConverter.escapeIdentifier(cl.getName(), connHsqldb); Object cnOld = memento[i]; Object cnNew = byAccess[i]; cnNew = ((String) cnNew).toUpperCase(); oldAutoValues.put(cl.getName(), cnOld); newAutoValues.put(cl.getName(), cnNew); try { conn.setFeedbackState(true);
private String getExpression(Column cl) throws IOException { PropertyMap map = cl.getProperties(); Property exprp = map.get(PropertyMap.EXPRESSION_PROP); if (exprp != null) { Table tl = cl.getTable(); String expr = SQLConverter.convertPowOperator((String) exprp.getValue()); for (Column cl1 : tl.getColumns()) { expr = expr.replaceAll("\\[(?i)(" + Pattern.quote(cl1.getName()) + ")\\]", "newrow.$0"); } return expr; } return null; }
private String getHsqldbColumnType(Column cl) throws IOException { String htype; DataType dtyp = cl.getType(); DataType rtyp = getReturnType(cl); boolean calcType = false; if (rtyp != null) { dtyp = rtyp; calcType = true; } if (dtyp.equals(DataType.TEXT)) { int ln = ff1997 ? cl.getLength() : cl.getLengthInUnits(); htype = "VARCHAR(" + ln + ")"; } else if (dtyp.equals(DataType.NUMERIC) && (cl.getScale() > 0 || calcType)) { if (calcType) { htype = "NUMERIC(100 ,4)"; } else { htype = "NUMERIC(" + (cl.getPrecision() > 0 ? cl.getPrecision() : 100) + "," + cl.getScale() + ")"; } } else if (dtyp.equals(DataType.FLOAT) && calcType) { htype = "NUMERIC(" + (cl.getPrecision() > 0 ? cl.getPrecision() : 100) + "," + 4 + ")"; } else { htype = TypesMap.map2hsqldb(dtyp); } return htype; }
public static boolean isMultiValueColumn(Table typeObjTable) { // if we found a single value of a "simple" type, then we are dealing with // a multi-value column List<? extends Column> typeCols = typeObjTable.getColumns(); return ((typeCols.size() == 1) && MULTI_VALUE_TYPES.contains(typeCols.get(0).getType())); }
@Override public void postTableLoadInit() throws IOException { super.postTableLoadInit(); // link up with the actual versioned column. it should have the same name // as the "value" column in the type table. Column versionedCol = getColumn().getTable().getColumn( getValueColumn().getName()); ((ColumnImpl)versionedCol).setVersionHistoryColumn((ColumnImpl)getColumn()); }
private static boolean anyUpdates(Joiner joiner,Object[] oldRow, Object[] newRow) { Table fromTable = joiner.getFromTable(); for(Index.Column iCol : joiner.getColumns()) { Column col = iCol.getColumn(); if(!MATCHER.matches(fromTable, col.getName(), col.getRowValue(oldRow), col.getRowValue(newRow))) { return true; } } return false; }
private static boolean hasAutoNumberColumn(Table t) { List<? extends Column> lc = t.getColumns(); for (Column cl : lc) { if (cl.isAutoNumber() || DataType.BOOLEAN.equals(cl.getType())) { return true; } } return false; }
private DataType getReturnType(Column cl) throws IOException { if (cl.getProperties().get(PropertyMap.EXPRESSION_PROP) == null || cl.getProperties().get(PropertyMap.RESULT_TYPE_PROP) == null) { return null; } byte pos = (Byte) cl.getProperties().get(PropertyMap.RESULT_TYPE_PROP).getValue(); return DataType.fromByte(pos); }
if (cl.getType() == DataType.COMPLEX_TYPE) { ComplexValueForeignKey rowFk = (ComplexValueForeignKey) cl.getRowValue(cur.getCurrentRow());
for (Column cli : t.getColumns()) { ColumnImpl cl = (ColumnImpl) cli; if (cli.getType().equals(DataType.COMPLEX_TYPE) && (newR[i] == null || "".equals(newR[i]))) { if (cli.getComplexInfo().getType().equals(ComplexDataType.ATTACHMENT)) { newR[i] = new JavaObjectData(new Attachment[0]); } else if (cli.getComplexInfo().getType().equals(ComplexDataType.MULTI_VALUE)) { newR[i] = new JavaObjectData(new SingleValue[0]);
private void saveColumnsDefaults(String[] defaults, Boolean[] required, Column cl, int j) throws IOException { PropertyMap map = cl.getProperties(); if (defaults != null && j < defaults.length && defaults[j] != null) { map.put(PropertyMap.DEFAULT_VALUE_PROP, DataType.TEXT, defaults[j]); } if (required != null && j < required.length && required[j] != null && !cl.isAutoNumber()) { map.put(PropertyMap.REQUIRED_PROP, DataType.BOOLEAN, required[j]); } map.save(); }