Skip to content

Commit

Permalink
added entity state to assignment extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jan 24, 2018
1 parent 2d96afb commit 7956ad7
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 17 deletions.
Expand Up @@ -116,13 +116,13 @@ public <T extends ObjectType> void addLinkRef() throws Exception {
ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, oid, UserType.F_GIVEN_NAME,
prismContext, new PolyString("asdf", "asdf"));

delta.addModificationAddProperty(new ItemPath(UserType.F_EXTENSION,
new QName("http://example.com/p", "weapon")), "glock");

delta.addModificationReplaceProperty(UserType.F_NAME, new PolyString("super name"));

delta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, new PolyString("one"));
delta.addModificationReplaceProperty(UserType.F_FAMILY_NAME, new PolyString("one"));
// delta.addModificationAddProperty(new ItemPath(UserType.F_EXTENSION,
// new QName("http://example.com/p", "weapon")), "glock");
//
// delta.addModificationReplaceProperty(UserType.F_NAME, new PolyString("super name"));
//
// delta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, new PolyString("one"));
// delta.addModificationReplaceProperty(UserType.F_FAMILY_NAME, new PolyString("one"));
// delta.addModificationAddProperty(UserType.F_EMPLOYEE_TYPE, "one","two");
// delta.addModificationReplaceProperty(new ItemPath(UserType.F_METADATA, MetadataType.F_CREATE_CHANNEL), "asdf");
// delta.addModificationReplaceProperty(
Expand All @@ -139,15 +139,15 @@ public <T extends ObjectType> void addLinkRef() throws Exception {
// delta.addModificationDeleteContainer(UserType.F_ASSIGNMENT, ass);


// ObjectReferenceType parentOrgRef = new ObjectReferenceType();
ObjectReferenceType parentOrgRef = new ObjectReferenceType();
// parentOrgRef.setType(OrgType.COMPLEX_TYPE);
// parentOrgRef.setOid("123");
// delta.addModificationDeleteReference(UserType.F_PARENT_ORG_REF, parentOrgRef.asReferenceValue());
//
// parentOrgRef = new ObjectReferenceType();
// parentOrgRef.setType(OrgType.COMPLEX_TYPE);
// parentOrgRef.setOid("789");
// delta.addModificationAddReference(UserType.F_PARENT_ORG_REF, parentOrgRef.asReferenceValue());
parentOrgRef = new ObjectReferenceType();
parentOrgRef.setType(OrgType.COMPLEX_TYPE);
parentOrgRef.setOid("789");
delta.addModificationAddReference(UserType.F_PARENT_ORG_REF, parentOrgRef.asReferenceValue());


// todo create modification for metadata/createApproverRef
Expand Down
Expand Up @@ -37,6 +37,8 @@
indexes = {@Index(name = "iAExtensionBoolean", columnNames = {"extensionType", "eName", "booleanValue"})})
public class RAExtBoolean implements RAExtValue {

private Boolean trans;

//owner entity
private RAssignmentExtension anyContainer;
private String ownerOid;
Expand All @@ -58,6 +60,17 @@ public RAExtBoolean(Boolean value) {
this.value = value;
}

@Transient
@Override
public Boolean isTransient() {
return trans;
}

@Override
public void setTransient(Boolean trans) {
this.trans = trans;
}

@ForeignKey(name = "fk_assignment_ext_boolean")
@MapsId("owner")
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Expand Up @@ -38,6 +38,8 @@
indexes = {@Index(name = "iAExtensionDate", columnNames = {"extensionType", "eName", "dateValue"})})
public class RAExtDate implements RAExtValue {

private Boolean trans;

//owner entity
private RAssignmentExtension anyContainer;
private String ownerOid;
Expand All @@ -59,6 +61,17 @@ public RAExtDate(Timestamp value) {
this.value = value;
}

@Transient
@Override
public Boolean isTransient() {
return trans;
}

@Override
public void setTransient(Boolean trans) {
this.trans = trans;
}

@ForeignKey(name = "fk_assignment_ext_date")
@MapsId("owner")
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Expand Up @@ -37,6 +37,8 @@
indexes = {@Index(name = "iAExtensionLong", columnNames = {"extensionType", "eName", "longValue"})})
public class RAExtLong implements RAExtValue {

private Boolean trans;

//owner entity
private RAssignmentExtension anyContainer;
private String ownerOid;
Expand All @@ -58,6 +60,17 @@ public RAExtLong(Long value) {
this.value = value;
}

@Transient
@Override
public Boolean isTransient() {
return trans;
}

@Override
public void setTransient(Boolean trans) {
this.trans = trans;
}

@ForeignKey(name = "fk_assignment_ext_long")
@MapsId("owner")
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Expand Up @@ -38,6 +38,8 @@
indexes = {@Index(name = "iAExtensionPolyString", columnNames = {"extensionType", "eName", "orig"})})
public class RAExtPolyString implements RAExtValue {

private Boolean trans;

//owner entity
private RAssignmentExtension anyContainer;
private String ownerOid;
Expand Down Expand Up @@ -65,6 +67,17 @@ public RAExtPolyString(PolyString polyString) {
}
}

@Transient
@Override
public Boolean isTransient() {
return trans;
}

@Override
public void setTransient(Boolean trans) {
this.trans = trans;
}

@ForeignKey(name = "fk_assignment_ext_poly")
@MapsId("owner")
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Expand Up @@ -40,6 +40,8 @@
indexes = {@Index(name = "iAExtensionReference", columnNames = {"extensionType", "eName", "targetoid"})})
public class RAExtReference implements RAExtValue {

private Boolean trans;

//owner entity
private RAssignmentExtension anyContainer;
private String ownerOid;
Expand All @@ -61,6 +63,17 @@ public class RAExtReference implements RAExtValue {
public RAExtReference() {
}

@Transient
@Override
public Boolean isTransient() {
return trans;
}

@Override
public void setTransient(Boolean trans) {
this.trans = trans;
}

@ForeignKey(name = "fk_assignment_ext_reference")
@MapsId("owner")
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Expand Up @@ -37,6 +37,8 @@
indexes = {@Index(name = "iAExtensionString", columnNames = {"extensionType", "eName", "stringValue"})})
public class RAExtString implements RAExtValue {

private Boolean trans;

//owner entity
private RAssignmentExtension anyContainer;
private String ownerOid;
Expand All @@ -58,6 +60,17 @@ public RAExtString(String value) {
this.value = value;
}

@Transient
@Override
public Boolean isTransient() {
return trans;
}

@Override
public void setTransient(Boolean trans) {
this.trans = trans;
}

@ForeignKey(name = "fk_assignment_ext_string")
@MapsId("owner")
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Expand Up @@ -16,12 +16,14 @@

package com.evolveum.midpoint.repo.sql.data.common.any;

import com.evolveum.midpoint.repo.sql.util.EntityState;

import java.io.Serializable;

/**
* @author lazyman
*/
public interface RAnyValue<T> extends Serializable {
public interface RAnyValue<T> extends Serializable, EntityState {

String F_VALUE = "value";

Expand Down
Expand Up @@ -2,12 +2,11 @@

import com.evolveum.midpoint.repo.sql.data.common.RObject;
import com.evolveum.midpoint.repo.sql.data.common.type.RObjectExtensionType;
import com.evolveum.midpoint.repo.sql.util.EntityState;

/**
* @author lazyman
*/
public interface ROExtValue extends RAnyValue, EntityState {
public interface ROExtValue extends RAnyValue {

String OWNER = "owner";

Expand Down
Expand Up @@ -48,6 +48,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -81,7 +82,14 @@ public <T extends ObjectType> RObject<T> update(Class<T> type, String oid, Colle
return merge(objectToMerge, session);
}

// todo how to generate identifiers correctly now? to repo entities and to full xml
// todo how to generate identifiers correctly now? to repo entities and to full xml, ids in full XML are generated on different place than we later create new containers...how to match them
// todo mark newly added containers/references as transient

// todo set proper owner/ownerOid for containers/references

// todo implement transformation from prism to entity (PrismEntityMapper)

// todo replace delta can mark entities as transient

RObject object = session.byId(objectToMerge.getClass()).getReference(oid);
object.setVersion(objectToMerge.getVersion());
Expand Down Expand Up @@ -453,7 +461,13 @@ private Class getRealOutputType(Attribute attribute) {

Method method = (Method) attribute.getJavaMember();
ParameterizedType parametrized = (ParameterizedType) method.getGenericReturnType();
return (Class) parametrized.getActualTypeArguments()[0];
Type t = parametrized.getActualTypeArguments()[0];
if (t instanceof Class) {
return (Class) t;
}

parametrized = (ParameterizedType) t;
return (Class) parametrized.getRawType();
}

private Object invoke(Object object, Method method) {
Expand Down

0 comments on commit 7956ad7

Please sign in to comment.