Skip to content

Commit

Permalink
Support for AbstractRole.ownerRef in repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Feb 29, 2016
1 parent a49caec commit a2b4151
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 19 deletions.
9 changes: 6 additions & 3 deletions config/sql/midpoint/3.4/h2/h2-3.4.sql
@@ -1,7 +1,10 @@
CREATE TABLE m_abstract_role (
approvalProcess VARCHAR(255),
requestable BOOLEAN,
oid VARCHAR(36) NOT NULL,
approvalProcess VARCHAR(255),
ownerRef_relation VARCHAR(157),
ownerRef_targetOid VARCHAR(36),
ownerRef_type INTEGER,
requestable BOOLEAN,
oid VARCHAR(36) NOT NULL,
PRIMARY KEY (oid)
);

Expand Down
4 changes: 4 additions & 0 deletions config/sql/midpoint/3.4/h2/h2-upgrade-3.3-3.4.sql
@@ -1,3 +1,7 @@
ALTER TABLE m_abstract_role ADD ownerRef_relation VARCHAR(157);
ALTER TABLE m_abstract_role ADD ownerRef_targetOid VARCHAR(36);
ALTER TABLE m_abstract_role ADD ownerRef_type INTEGER;

ALTER TABLE m_acc_cert_campaign ADD endTimestamp TIMESTAMP;
ALTER TABLE m_acc_cert_campaign ADD handlerUri VARCHAR(255);
ALTER TABLE m_acc_cert_campaign ADD ownerRef_relation VARCHAR(157);
Expand Down
4 changes: 4 additions & 0 deletions config/sql/midpoint/3.4/h2/h2-upgrade-3.4-SNAPSHOT-2.sql
@@ -0,0 +1,4 @@
ALTER TABLE m_abstract_role ADD ownerRef_relation VARCHAR(157);
ALTER TABLE m_abstract_role ADD ownerRef_targetOid VARCHAR(36);
ALTER TABLE m_abstract_role ADD ownerRef_type INTEGER;

9 changes: 6 additions & 3 deletions config/sql/midpoint/3.4/mysql/mysql-3.4.sql
Expand Up @@ -12,9 +12,12 @@
# remove iAncestor and iDescendant index, they are the same as FK for that fields

CREATE TABLE m_abstract_role (
approvalProcess VARCHAR(255),
requestable BIT,
oid VARCHAR(36) NOT NULL,
approvalProcess VARCHAR(255),
ownerRef_relation VARCHAR(157),
ownerRef_targetOid VARCHAR(36),
ownerRef_type INTEGER,
requestable BIT,
oid VARCHAR(36) NOT NULL,
PRIMARY KEY (oid)
)
DEFAULT CHARACTER SET utf8
Expand Down
5 changes: 5 additions & 0 deletions config/sql/midpoint/3.4/mysql/mysql-upgrade-3.3-3.4.sql
@@ -1,3 +1,8 @@
ALTER TABLE m_abstract_role
ADD ownerRef_relation VARCHAR(157),
ADD ownerRef_targetOid VARCHAR(36),
ADD ownerRef_type INTEGER;

ALTER TABLE m_acc_cert_campaign
ADD endTimestamp DATETIME(6),
ADD handlerUri VARCHAR(255),
Expand Down
@@ -0,0 +1,5 @@
ALTER TABLE m_abstract_role
ADD ownerRef_relation VARCHAR(157),
ADD ownerRef_targetOid VARCHAR(36),
ADD ownerRef_type INTEGER;

9 changes: 6 additions & 3 deletions config/sql/midpoint/3.4/oracle/oracle-3.4.sql
Expand Up @@ -2,9 +2,12 @@
-- replace ");" with ") INITRANS 30;"

CREATE TABLE m_abstract_role (
approvalProcess VARCHAR2(255 CHAR),
requestable NUMBER(1, 0),
oid VARCHAR2(36 CHAR) NOT NULL,
approvalProcess VARCHAR2(255 CHAR),
ownerRef_relation VARCHAR2(157 CHAR),
ownerRef_targetOid VARCHAR2(36 CHAR),
ownerRef_type NUMBER(10, 0),
requestable NUMBER(1, 0),
oid VARCHAR2(36 CHAR) NOT NULL,
PRIMARY KEY (oid)
) INITRANS 30;

Expand Down
6 changes: 6 additions & 0 deletions config/sql/midpoint/3.4/oracle/oracle-upgrade-3.3-3.4.sql
@@ -1,3 +1,9 @@
ALTER TABLE m_abstract_role ADD (
ownerRef_relation VARCHAR2(157 CHAR),
ownerRef_targetOid VARCHAR2(36 CHAR),
ownerRef_type NUMBER(10, 0)
);

ALTER TABLE m_acc_cert_campaign ADD (
endTimestamp TIMESTAMP,
handlerUri VARCHAR2(255 CHAR),
Expand Down
@@ -0,0 +1,6 @@
ALTER TABLE m_abstract_role ADD (
ownerRef_relation VARCHAR2(157 CHAR),
ownerRef_targetOid VARCHAR2(36 CHAR),
ownerRef_type NUMBER(10, 0)
);

9 changes: 6 additions & 3 deletions config/sql/midpoint/3.4/postgresql/postgresql-3.4.sql
@@ -1,7 +1,10 @@
CREATE TABLE m_abstract_role (
approvalProcess VARCHAR(255),
requestable BOOLEAN,
oid VARCHAR(36) NOT NULL,
approvalProcess VARCHAR(255),
ownerRef_relation VARCHAR(157),
ownerRef_targetOid VARCHAR(36),
ownerRef_type INT4,
requestable BOOLEAN,
oid VARCHAR(36) NOT NULL,
PRIMARY KEY (oid)
);

Expand Down
@@ -1,3 +1,8 @@
ALTER TABLE m_abstract_role
ADD ownerRef_relation VARCHAR(157),
ADD ownerRef_targetOid VARCHAR(36),
ADD ownerRef_type INT4;

ALTER TABLE m_acc_cert_campaign
ADD endTimestamp TIMESTAMP,
ADD handlerUri VARCHAR(255),
Expand Down
@@ -0,0 +1,5 @@
ALTER TABLE m_abstract_role
ADD ownerRef_relation VARCHAR(157),
ADD ownerRef_targetOid VARCHAR(36),
ADD ownerRef_type INT4;

9 changes: 6 additions & 3 deletions config/sql/midpoint/3.4/sqlserver/sqlserver-3.4.sql
@@ -1,7 +1,10 @@
CREATE TABLE m_abstract_role (
approvalProcess NVARCHAR(255) COLLATE database_default,
requestable BIT,
oid NVARCHAR(36) COLLATE database_default NOT NULL,
approvalProcess NVARCHAR(255) COLLATE database_default,
ownerRef_relation NVARCHAR(157) COLLATE database_default,
ownerRef_targetOid NVARCHAR(36) COLLATE database_default,
ownerRef_type INT,
requestable BIT,
oid NVARCHAR(36) COLLATE database_default NOT NULL,
PRIMARY KEY (oid)
);

Expand Down
@@ -1,3 +1,8 @@
ALTER TABLE m_abstract_role ADD
ownerRef_relation NVARCHAR(157) COLLATE database_default,
ownerRef_targetOid NVARCHAR(36) COLLATE database_default,
ownerRef_type INT;

ALTER TABLE m_acc_cert_campaign ADD
endTimestamp DATETIME2,
handlerUri NVARCHAR(255) COLLATE database_default,
Expand Down
@@ -0,0 +1,5 @@
ALTER TABLE m_abstract_role ADD
ownerRef_relation NVARCHAR(157) COLLATE database_default,
ownerRef_targetOid NVARCHAR(36) COLLATE database_default,
ownerRef_type INT;

Expand Up @@ -2355,6 +2355,38 @@ public void test600QueryObjectypeByTypeComplex() throws Exception {
}
}

@Test
public void test605QueryObjectypeByTypeAndReference() throws Exception {
Session session = open();
try {
PrismObjectDefinition<RoleType> roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class);
ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, prismContext)
.id("c0c010c0-d34d-b33f-f00d-111111111111")
.or().type(RoleType.class)
.item(roleDef, RoleType.F_OWNER_REF).ref("c0c010c0-d34d-b33f-f00d-111111111111")
.build();
String real = getInterpretedQuery2(session, ObjectType.class, query);
String expected = "select o.fullObject, o.stringsCount, o.longsCount, o.datesCount, o.referencesCount, o.polysCount, o.booleansCount\n"
+ "from\n"
+ " RObject o\n"
+ "where\n"
+ " (\n"
+ " o.oid in :oid or\n"
+ " (\n"
+ " o.objectTypeClass = :objectTypeClass and\n"
+ " (\n"
+ " o.ownerRef.targetOid = :targetOid and\n"
+ " o.ownerRef.relation = :relation\n"
+ " )\n"
+ " )\n"
+ " )\n";

assertEqualsIgnoreWhitespace(expected, real);
} finally {
close(session);
}
}

@Test(expectedExceptions = QueryException.class)
public void test610QueryGenericClob() throws Exception {
Session session = open();
Expand Down
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.repo.sql.data.common.container.RAssignment;
import com.evolveum.midpoint.repo.sql.data.common.container.RExclusion;
import com.evolveum.midpoint.repo.sql.data.common.embedded.REmbeddedReference;
import com.evolveum.midpoint.repo.sql.data.common.other.RAssignmentOwner;
import com.evolveum.midpoint.repo.sql.data.common.other.RReferenceOwner;
import com.evolveum.midpoint.repo.sql.query.definition.JaxbName;
Expand All @@ -40,10 +41,7 @@
import org.hibernate.annotations.Persister;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

Expand All @@ -68,6 +66,8 @@ public abstract class RAbstractRole<T extends AbstractRoleType> extends RFocus<T
private Set<RObjectReference<RFocus>> approverRef;
private String approvalProcess;

private REmbeddedReference ownerRef;

public Boolean getRequestable() {
return requestable;
}
Expand Down Expand Up @@ -103,6 +103,11 @@ public Set<RObjectReference<RFocus>> getApproverRef() {
return approverRef;
}

@Embedded
public REmbeddedReference getOwnerRef() {
return ownerRef;
}

public void setApproverRef(Set<RObjectReference<RFocus>> approverRef) {
this.approverRef = approverRef;
}
Expand All @@ -115,6 +120,10 @@ public void setApprovalProcess(String approvalProcess) {
this.approvalProcess = approvalProcess;
}

public void setOwnerRef(REmbeddedReference ownerRef) {
this.ownerRef = ownerRef;
}

public void setRequestable(Boolean requestable) {
this.requestable = requestable;
}
Expand All @@ -138,6 +147,8 @@ public boolean equals(Object o) {
return false;
if (requestable != null ? !requestable.equals(that.requestable) : that.requestable != null)
return false;
if (ownerRef != null ? !ownerRef.equals(that.ownerRef) : that.ownerRef != null)
return false;

return true;
}
Expand All @@ -147,6 +158,7 @@ public int hashCode() {
int result = super.hashCode();
result = 31 * result + (approvalProcess != null ? approvalProcess.hashCode() : 0);
result = 31 * result + (requestable != null ? requestable.hashCode() : 0);
result = 31 * result + (ownerRef != null ? ownerRef.hashCode() : 0);
return result;
}

Expand Down Expand Up @@ -181,5 +193,7 @@ public static <T extends AbstractRoleType> void copyFromJAXB(AbstractRoleType ja
PrismObjectDefinition<AbstractRoleType> roleDefinition = jaxb.asPrismObject().getDefinition();

repo.setApprovalProcess(jaxb.getApprovalProcess());

repo.setOwnerRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getOwnerRef(), prismContext));
}
}

0 comments on commit a2b4151

Please sign in to comment.