use of org.apache.cayenne.access.DataDomainSyncBucket.PropagatedValueFactory in project cayenne by apache.
the class FlattenedArcKey method lazyJoinSnapshot.
private Map<String, Object> lazyJoinSnapshot() {
List<DbRelationship> relList = relationship.getDbRelationships();
if (relList.size() != 2) {
throw new CayenneRuntimeException("Only single-step flattened relationships are supported in this operation: %s", relationship);
}
DbRelationship firstDbRel = relList.get(0);
DbRelationship secondDbRel = relList.get(1);
List<DbJoin> fromSourceJoins = firstDbRel.getJoins();
List<DbJoin> toTargetJoins = secondDbRel.getJoins();
Map<String, Object> snapshot = new HashMap<>(fromSourceJoins.size() + toTargetJoins.size(), 1);
for (DbJoin join : fromSourceJoins) {
Object value = new PropagatedValueFactory(id1.getSourceId(), join.getSourceName());
snapshot.put(join.getTargetName(), value);
}
for (DbJoin join : toTargetJoins) {
Object value = new PropagatedValueFactory(id2.getSourceId(), join.getTargetName());
snapshot.put(join.getSourceName(), value);
}
return snapshot;
}
use of org.apache.cayenne.access.DataDomainSyncBucket.PropagatedValueFactory in project cayenne by apache.
the class DataDomainDBDiffBuilder method appendForeignKeys.
private void appendForeignKeys(Map<String, Object> dbDiff) {
// populate changed FKs
if (currentArcDiff != null) {
for (Entry<Object, Object> entry : currentArcDiff.entrySet()) {
DbRelationship dbRelation;
String arcIdString = entry.getKey().toString();
ObjRelationship relation = objEntity.getRelationship(arcIdString);
if (relation == null) {
dbRelation = dbEntity.getRelationship(arcIdString.substring(ASTDbPath.DB_PREFIX.length()));
} else {
dbRelation = relation.getDbRelationships().get(0);
}
// In case of a vertical inheritance, ensure that it belongs to this bucket...
if (dbRelation.getSourceEntity() == dbEntity) {
ObjectId targetId = (ObjectId) entry.getValue();
for (DbJoin join : dbRelation.getJoins()) {
Object value = (targetId != null) ? new PropagatedValueFactory(targetId, join.getTargetName()) : null;
dbDiff.put(join.getSourceName(), value);
}
}
}
}
}
Aggregations