/** * Returns true if a given attribute always has a null value in the batch. * * @since 1.1 */ public boolean isNull(DbAttribute attribute) { return nullQualifierNames.contains(attribute.getName()); }
/** * Returns true if a given attribute always has a null value in the batch. * * @since 1.2 */ public boolean isNull(DbAttribute attribute) { return nullQualifierNames.contains(attribute.getName()); }
@Override public Object getValue(int i) { return qualifier.get(dbAttributes.get(i).getName()); } });
public SetPrimaryKeyToModel(DbEntity entity, Collection<DbAttribute> primaryKeyOriginal, Collection<DbAttribute> primaryKeyNew, String detectedPrimaryKeyName) { super("Set Primary Key", 105, entity); this.primaryKeyOriginal = primaryKeyOriginal; this.primaryKeyNew = primaryKeyNew; this.detectedPrimaryKeyName = detectedPrimaryKeyName; for (DbAttribute attr : primaryKeyNew) { primaryKeyNewAttributeNames.add(attr.getName().toUpperCase()); } }
@Override protected Expression buildIdQualifier(Object id) { return ExpressionFactory.matchDbExp(pk.getName(), id); }
public Object transform(Object input) { ObjectId id = (ObjectId) ((ObjectDiff) input).getNodeId(); return id.getIdSnapshot().get(attribute.getName()); } });
public Object transform(Object input) { ObjectId id = (ObjectId) ((ObjectDiff) input).getNodeId(); return id.getIdSnapshot().get(attribute.getName()); } });
@Override public void write(DataObject target, Object value) { // regular meaningless PK target.getObjectId().getReplacementIdMap().put(pk.getName(), value); }
public MapperBuilder matchById() { Collection<DbAttribute> pks = entity.getDbEntity().getPrimaryKeys(); if (pks.isEmpty()) { throw new IllegalStateException("Target entity has no PKs defined: " + entity.getDbEntityName()); } for (DbAttribute pk : pks) { this.paths.add(ASTDbPath.DB_PREFIX + pk.getName()); } return this; }
public TargetPkPropertyWriter(DbAttribute pk) { if (!pk.isPrimaryKey()) { throw new LmRuntimeException("'" + pk.getName() + "' is not a PK"); } this.pk = pk; }
public boolean visitToOne(ToOneProperty property) { ObjRelationship rel = property.getRelationship(); DbRelationship dbRel = rel.getDbRelationships().get(0); for (DbJoin join : dbRel.getJoins()) { DbAttribute src = join.getSource(); if (src.isForeignKey() && visited.add(src.getName())) { entityResult.addDbField(src.getName(), prefix + index[0]++); } } return true; } };
private boolean visitRelationship(ArcProperty arc) { DbRelationship dbRel = arc.getRelationship().getDbRelationships().get(0); for (DbAttribute attribute : dbRel.getSourceAttributes()) { String target = attribute.getName(); appendColumn(targetSource, target, prefix + target); } return true; } });
@Override public List<String> createSql(DbAdapter adapter) { return Collections.singletonList("ALTER TABLE " + getEntity().getFullyQualifiedName() + " ALTER COLUMN " + getColumn().getName() + " SET NULL"); }
@Override public List<String> createSql(DbAdapter adapter) { return Collections.singletonList("ALTER TABLE " + getEntity().getFullyQualifiedName() + " COLUMN " + getColumn().getName() + " SET NOT NULL"); }
@Override public List<String> createSql(DbAdapter adapter) { return Collections.singletonList("ALTER TABLE " + getEntity().getFullyQualifiedName() + " COLUMN " + getColumn().getName() + " SET NULL"); }
@Override public void logGeneratedKey(DbAttribute attribute, Object value) { if (isLoggable()) { String entity = attribute.getEntity().getName(); logger.info("Generated PK: " + entity + "." + attribute.getName() + " = " + value); } }
private void addMissingAttribute(ObjEntity entity, DbAttribute da) { ObjAttribute oa = new ObjAttribute(); oa.setName(NameBuilder.builder(oa, entity).baseName(nameGenerator.objAttributeName(da)).name()); oa.setEntity(entity); oa.setType(getTypeForObjAttribute(da)); oa.setDbAttributePath(da.getName()); entity.addAttribute(oa); fireAttributeAdded(oa); }