_strategy = info.getStrategy(); if (_canIdx && _idx == null) { if (info.getIndex() != null) _idx = info.getIndex(); else _canIdx = info.canIndex(); if (info.getUnique() != null) _unq = info.getUnique(); else _canUnq = info.canUnique(); if (info.getForeignKey() != null) _fk = info.getForeignKey(); else _canFK = info.canForeignKey(); _implicitRelation = info.isImplicitRelation(); List<Column> cols = getColumns(); List<Column> icols = info.getColumns(); if (!icols.isEmpty() && (cols.isEmpty() || cols.size() == icols.size())) { ((Column) cols.get(i)).copy((Column) icols.get(i)); setColumns(cols);
/** * Assert that the user did not supply any columns, index, unique * constraint, or foreign key for this mapping. */ public void assertNoSchemaComponents(MetaDataContext context, boolean die) { if (_cols == null || _cols.isEmpty()) { assertNoIndex(context, die); assertNoUnique(context, die); assertNoForeignKey(context, die); return; } Message msg = _loc.get("unexpected-cols", context); if (die) throw new MetaDataException(msg); context.getRepository().getLog().warn(msg); }
/** * Serialize the columns in the given mapping info. */ private void serializeColumns(MappingInfo info, ColType type, String secondary) throws SAXException { List<Column> cols = (List<Column>) info.getColumns(); if (cols == null) return; for (Column col : cols) serializeColumn(col, type, secondary, info.getUnique() != null); }
/** * Set the given map key column as the map key column for <code>fm</code>. * * @param unique bitwise combination of TRUE and FALSE for the * unique attribute of the column */ protected void setMapKeyColumn(FieldMapping fm, MappingInfo info, Column col, int unique) { List<Column> cols = new ArrayList<Column>(); cols.add(col); info.setColumns(cols); if (unique == TRUE) info.setUnique(new org.apache.openjpa.jdbc.schema.Unique()); }
/** * Use the join information to populate our internal column I/O data. */ private void setIOFromJoins(ForeignKey fk, Object[][] joins) { List cols = getColumns(); _io = null; if (cols.isEmpty()) return; int constIdx = 0; int idx; for (int i = 0; i < joins.length; i++) { // const columns are indexed after std join columns in fk IO if (joins[i][1]instanceof Column) idx = i - constIdx; else if ((joins[i][2] == Boolean.TRUE) == (_join == JOIN_INVERSE)) idx = fk.getColumns().length + constIdx++; else continue; setIOFromColumnFlags((Column) cols.get(i), idx); } }
assertTable(context, table); if (prefix == null) prefix = "generic"; List given = getColumns(); boolean fill = ((MappingRepository) context.getRepository()). getMappingDefaults().defaultMissingInfo(); for (int i = 0; i < tmplates.length; i++) { col = (given.isEmpty()) ? null : (Column) given.get(i); cols[i] = mergeColumn(context, prefix, tmplates[i], true, col, table, adapt, fill); setIOFromColumnFlags(col, i);
String prefix, List given, ForeignKeyDefaults def, Table table, ClassMapping cls, ClassMapping rel, boolean inversable, boolean adapt) { assertTable(context, table); if (prefix == null) prefix = "generic"; Object[][] joins = createJoins(context, prefix, table, cls, rel, given, def, inversable, adapt); _join = JOIN_FORWARD; exist.setDeleteAction(_fk.getDeleteAction()); setIOFromJoins(exist, joins); return exist; fk.joinConstant(col, joins[i][1]); setIOFromJoins(fk, joins); return fk;
Column tmplate, boolean compat, Column given, Table table, boolean adapt, boolean fill) { assertTable(context, table); colName = colName.substring(1); else if (dotIdx != -1) { findTable(context, colName.substring(0, dotIdx), table, null, null); colName = colName.substring(dotIdx + 1);
/** * Gets the columns whose table name matches the given table name. * @deprecated */ public List<Column> getColumns(String tableName) { return getColumns(DBIdentifier.newTable(tableName)); }
/** * Parse map-key-column. */ private boolean startMapKeyColumn(Attributes attrs) throws SAXException { FieldMapping fm = (FieldMapping) peekElement(); Column col = parseColumn(attrs); MappingInfo info = fm.getKeyMapping().getValueInfo(); List<Column> cols = new ArrayList<Column>(); cols.add(col); info.setColumns(cols); return true; }
assertTable(context, table); if (prefix == null) prefix = "generic"; List<Column> given = getColumns(); && given.size() != tmplates.length) { given = getColumns(table.getIdentifier()); if ((!adapt && !fill) && given.size() != tmplates.length) { given = getColumns(""); if ((!adapt && !fill) && given.size() != tmplates.length) { throw new MetaDataException(_loc.get(prefix + "-num-cols", for (int i = 0; i < tmplates.length; i++) { col = (given.isEmpty()) ? null : (Column) given.get(i); cols[i] = mergeColumn(context, prefix, tmplates[i], true, col, table, adapt, fill); setIOFromColumnFlags(col, i);
/** * Serialize the columns in the given mapping info. */ private void serializeColumns(MappingInfo info, ColType type, String secondary) throws SAXException { List<Column> cols = (List<Column>) info.getColumns(); if (cols == null) return; for (Column col : cols) serializeColumn(col, type, secondary, info.getUnique() != null); }
String prefix, List<Column> given, ForeignKeyDefaults def, Table table, ClassMapping cls, ClassMapping rel, boolean inversable, boolean adapt) { assertTable(context, table); if (prefix == null) prefix = "generic"; Object[][] joins = createJoins(context, prefix, table, cls, rel, given, def, inversable, adapt); _join = JOIN_FORWARD; exist.setDeleteAction(_fk.getDeleteAction()); setIOFromJoins(exist, joins); return exist; fk.joinConstant(col, joins[i][1]); setIOFromJoins(fk, joins); return fk;
/** * Set the given map key column as the map key column for <code>fm</code>. * * @param unique bitwise combination of TRUE and FALSE for the * unique attribute of the column */ protected void setMapKeyColumn(FieldMapping fm, MappingInfo info, Column col, int unique) { List<Column> cols = new ArrayList<Column>(); cols.add(col); info.setColumns(cols); if (unique == TRUE) info.setUnique(new org.apache.openjpa.jdbc.schema.Unique()); }
/** * Use the join information to populate our internal column I/O data. */ private void setIOFromJoins(ForeignKey fk, Object[][] joins) { List<Column> cols = getColumns(); _io = null; if (cols.isEmpty()) return; int constIdx = 0; int idx; for (int i = 0; i < joins.length; i++) { // const columns are indexed after std join columns in fk IO if (joins[i][1]instanceof Column) idx = i - constIdx; else if ((joins[i][2] == Boolean.TRUE) == (_join == JOIN_INVERSE)) idx = fk.getColumns().length + constIdx++; else continue; setIOFromColumnFlags((Column) cols.get(i), idx); } }
Column tmplate, boolean compat, Column given, Table table, boolean adapt, boolean fill) { assertTable(context, table); colName = path.getIdentifier(); } else if (!DBIdentifier.isNull(path.getObjectTableName())) { findTable(context, path.getObjectTableName(), table, null, null); colName = path.getUnqualifiedName();
/** * Gets the columns whose table name matches the given table name. * @deprecated */ public List<Column> getColumns(String tableName) { return getColumns(DBIdentifier.newTable(tableName)); }
/** * Parse map-key-column. */ private boolean startMapKeyColumn(Attributes attrs) throws SAXException { FieldMapping fm = (FieldMapping) peekElement(); Column col = parseColumn(attrs); MappingInfo info = fm.getKeyMapping().getValueInfo(); List<Column> cols = new ArrayList<Column>(); cols.add(col); info.setColumns(cols); return true; }
_strategy = info.getStrategy(); if (_canIdx && _idx == null) { if (info.getIndex() != null) _idx = info.getIndex(); else _canIdx = info.canIndex(); if (info.getUnique() != null) _unq = info.getUnique(); else _canUnq = info.canUnique(); if (info.getForeignKey() != null) _fk = info.getForeignKey(); else _canFK = info.canForeignKey(); _implicitRelation = info.isImplicitRelation(); List<Column> cols = getColumns(); List<Column> icols = info.getColumns(); if (!icols.isEmpty() && (cols.isEmpty() || cols.size() == icols.size())) { ((Column) cols.get(i)).copy((Column) icols.get(i)); setColumns(cols);
assertTable(context, table); if (prefix == null) prefix = "generic"; List<Column> given = getColumns(); && given.size() != tmplates.length) { given = getColumns(table.getIdentifier()); if ((!adapt && !fill) && given.size() != tmplates.length) { given = getColumns(""); if ((!adapt && !fill) && given.size() != tmplates.length) { throw new MetaDataException(_loc.get(prefix + "-num-cols", for (int i = 0; i < tmplates.length; i++) { col = (given.isEmpty()) ? null : (Column) given.get(i); cols[i] = mergeColumn(context, prefix, tmplates[i], true, col, table, adapt, fill); setIOFromColumnFlags(col, i);