Skip to content

Commit

Permalink
MID-3584 MID-4224 updated repo annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Nov 3, 2017
1 parent a25c8be commit 28ff236
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 25 deletions.
3 changes: 3 additions & 0 deletions repo/repo-sql-impl-test/src/test/resources/basic/objects.xml
Expand Up @@ -1089,6 +1089,9 @@
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3">
<name>Pirate</name>
<roleType>business</roleType>
<autoassign>
<enabled>true</enabled>
</autoassign>
</role>

<org oid="00000000-8888-6666-0000-100000000085">
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.repo.sql.data.RepositoryContext;
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.RAutoassignSpecification;
import com.evolveum.midpoint.repo.sql.data.common.embedded.REmbeddedReference;
import com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString;
import com.evolveum.midpoint.repo.sql.data.common.other.RAssignmentOwner;
Expand Down Expand Up @@ -58,7 +59,8 @@
@org.hibernate.annotations.Table(appliesTo = "m_abstract_role",
indexes = {
@Index(name = "iAbstractRoleIdentifier", columnNames = "identifier"),
@Index(name = "iRequestable", columnNames = "requestable")}) // TODO correct index name
@Index(name = "iRequestable", columnNames = "requestable"),
@Index(name = "iAutoassignEnabled", columnNames = "autoassign_enabled")})
@Persister(impl = MidPointJoinedPersister.class)
public abstract class RAbstractRole<T extends AbstractRoleType> extends RFocus<T> {

Expand All @@ -72,6 +74,8 @@ public abstract class RAbstractRole<T extends AbstractRoleType> extends RFocus<T

private REmbeddedReference ownerRef;

private RAutoassignSpecification autoassign;

public Boolean getRequestable() {
return requestable;
}
Expand Down Expand Up @@ -157,44 +161,49 @@ public void setDisplayName(RPolyString displayName) {
this.displayName = displayName;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (!super.equals(o))
return false;
public RAutoassignSpecification getAutoassign() {
return autoassign;
}

RAbstractRole that = (RAbstractRole) o;
public void setAutoassign(RAutoassignSpecification autoassign) {
this.autoassign = autoassign;
}

if (exclusion != null ? !exclusion.equals(that.exclusion) : that.exclusion != null)
return false;
if (approverRef != null ? !approverRef.equals(that.approverRef) : that.approverRef != null)
return false;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;

RAbstractRole<?> that = (RAbstractRole<?>) o;

if (identifier != null ? !identifier.equals(that.identifier) : that.identifier != null) return false;
if (riskLevel != null ? !riskLevel.equals(that.riskLevel) : that.riskLevel != null) return false;
if (displayName != null ? !displayName.equals(that.displayName) : that.displayName != null) return false;
if (exclusion != null ? !exclusion.equals(that.exclusion) : that.exclusion != null) return false;
if (requestable != null ? !requestable.equals(that.requestable) : that.requestable != null) return false;
if (approverRef != null ? !approverRef.equals(that.approverRef) : that.approverRef != null) return false;
if (approvalProcess != null ? !approvalProcess.equals(that.approvalProcess) : that.approvalProcess != null)
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;
if (displayName != null ? !displayName.equals(that.displayName) : that.displayName != null) return false;
if (identifier != null ? !identifier.equals(that.identifier) : that.identifier != null) return false;

return true;
if (ownerRef != null ? !ownerRef.equals(that.ownerRef) : that.ownerRef != null) return false;
return autoassign != null ? autoassign.equals(that.autoassign) : that.autoassign == null;
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (approvalProcess != null ? approvalProcess.hashCode() : 0);
result = 31 * result + (identifier != null ? identifier.hashCode() : 0);
result = 31 * result + (riskLevel != null ? riskLevel.hashCode() : 0);
result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
result = 31 * result + (requestable != null ? requestable.hashCode() : 0);
result = 31 * result + (approvalProcess != null ? approvalProcess.hashCode() : 0);
result = 31 * result + (ownerRef != null ? ownerRef.hashCode() : 0);
result = 31 * result + (autoassign != null ? autoassign.hashCode() : 0);
return result;
}

public static <T extends AbstractRoleType> void copyFromJAXB(AbstractRoleType jaxb, RAbstractRole<T> repo,
RepositoryContext repositoryContext, IdGeneratorResult generatorResult)
RepositoryContext repositoryContext, IdGeneratorResult generatorResult)
throws DtoTranslationException {

RFocus.copyFromJAXB(jaxb, repo, repositoryContext, generatorResult);
Expand All @@ -204,6 +213,12 @@ public static <T extends AbstractRoleType> void copyFromJAXB(AbstractRoleType ja
repo.setIdentifier(jaxb.getIdentifier());
repo.setRiskLevel(jaxb.getRiskLevel());

if (jaxb.getAutoassign() != null) {
RAutoassignSpecification aa = new RAutoassignSpecification();
RAutoassignSpecification.copyFromJAXB(jaxb.getAutoassign(), aa);
repo.setAutoassign(aa);
}

for (AssignmentType inducement : jaxb.getInducement()) {
RAssignment rInducement = new RAssignment(repo, RAssignmentOwner.ABSTRACT_ROLE);
RAssignment.copyFromJAXB(inducement, rInducement, jaxb, repositoryContext, generatorResult);
Expand Down
Expand Up @@ -273,7 +273,7 @@ public String getNode() {
return node;
}

@Column(nullable = true)
@Column(nullable = true, unique = true)
public String getTaskIdentifier() {
return taskIdentifier;
}
Expand Down
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

import com.evolveum.midpoint.xml.ns._public.common.common_3.AutoassignSpecificationType;
import org.apache.commons.lang3.Validate;

import javax.persistence.Embeddable;

/**
* Created by Viliam Repan (lazyman).
*/
@Embeddable
public class RAutoassignSpecification {

private Boolean enabled;

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

RAutoassignSpecification that = (RAutoassignSpecification) o;

return enabled != null ? enabled.equals(that.enabled) : that.enabled == null;
}

@Override
public int hashCode() {
return enabled != null ? enabled.hashCode() : 0;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("RAutoassignSpecification{");
sb.append("enabled=").append(enabled);
sb.append('}');
return sb.toString();
}

public static void copyFromJAXB(AutoassignSpecificationType aa, RAutoassignSpecification raa) {
Validate.notNull(aa, "Autoassign specification type must not be null");
Validate.notNull(raa, "Repo autoassign specification must not be null");

raa.setEnabled(aa.isEnabled());
}
}

0 comments on commit 28ff236

Please sign in to comment.