-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sqale: Created common superclass for containers with full objects
- Loading branch information
1 parent
94e5649
commit 2e5e147
Showing
18 changed files
with
164 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...rc/main/java/com/evolveum/midpoint/repo/sqale/qmodel/common/MContainerWithFullObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.evolveum.midpoint.repo.sqale.qmodel.common; | ||
|
||
public class MContainerWithFullObject extends MContainer { | ||
|
||
public byte[] fullObject; | ||
} |
20 changes: 20 additions & 0 deletions
20
...rc/main/java/com/evolveum/midpoint/repo/sqale/qmodel/common/QContainerWithFullObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.evolveum.midpoint.repo.sqale.qmodel.common; | ||
|
||
import com.querydsl.core.types.dsl.ArrayPath; | ||
import com.querydsl.sql.ColumnMetadata; | ||
|
||
import java.sql.Types; | ||
|
||
public class QContainerWithFullObject<R extends MContainerWithFullObject, OR> extends QContainer<R, OR> { | ||
|
||
|
||
public static final ColumnMetadata FULL_OBJECT = | ||
ColumnMetadata.named("fullObject").ofType(Types.BINARY); | ||
|
||
public final ArrayPath<byte[], Byte> fullObject = createByteArray("fullObject", FULL_OBJECT); | ||
|
||
public QContainerWithFullObject(Class<? extends R> type, String variable, String schema, String table) { | ||
super(type, variable, schema, table); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
.../java/com/evolveum/midpoint/repo/sqale/qmodel/common/QContainerWithFullObjectMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.evolveum.midpoint.repo.sqale.qmodel.common; | ||
|
||
import com.evolveum.midpoint.prism.Containerable; | ||
import com.evolveum.midpoint.prism.PrismContainer; | ||
import com.evolveum.midpoint.prism.PrismContainerValue; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.repo.sqale.SqaleRepoContext; | ||
|
||
import com.evolveum.midpoint.repo.sqale.qmodel.assignment.MAssignment; | ||
import com.evolveum.midpoint.repo.sqale.update.SqaleUpdateContext; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public abstract class QContainerWithFullObjectMapping<S extends Containerable, Q extends QContainerWithFullObject<R, OR>, R extends MContainerWithFullObject, OR> extends QContainerMapping<S,Q,R,OR> { | ||
|
||
protected QContainerWithFullObjectMapping(@NotNull String tableName, @NotNull String defaultAliasName, @NotNull Class<S> schemaType, @NotNull Class<Q> queryType, @NotNull SqaleRepoContext repositoryContext) { | ||
super(tableName, defaultAliasName, schemaType, queryType, repositoryContext); | ||
} | ||
|
||
abstract protected ItemPath getContainerPath(); | ||
|
||
public R initRowObjectWithFullObject(S schemaObject, OR ownerRow) throws SchemaException { | ||
R row = super.initRowObject(schemaObject, ownerRow); | ||
row.fullObject = createFullObject(schemaObject); | ||
return row; | ||
} | ||
|
||
@Override | ||
public void afterModify(SqaleUpdateContext<S, Q, R> updateContext) throws SchemaException { | ||
super.afterModify(updateContext); | ||
// insert fullObject here | ||
PrismContainer<AssignmentType> identityContainer = | ||
updateContext.findValueOrItem(getContainerPath()); | ||
// row in context already knows its CID | ||
PrismContainerValue<AssignmentType> pcv = identityContainer.findValue(updateContext.row().cid); | ||
byte[] fullObject = createFullObject(pcv.asContainerable()); | ||
updateContext.set(updateContext.entityPath().fullObject, fullObject); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.