Skip to content

Commit

Permalink
Adapting Certification Manager to new repo implementation. Still miss…
Browse files Browse the repository at this point in the history
…ing intra-case updates, sorting and "no response" filters.
  • Loading branch information
mederly committed Nov 25, 2015
1 parent c8f57e9 commit 393fe6b
Show file tree
Hide file tree
Showing 24 changed files with 641 additions and 407 deletions.
Expand Up @@ -78,7 +78,7 @@ public Iterator<CertDecisionDto> internalIterator(long first, long count) {
SelectorOptions.createCollection(GetOperationOptions.createResolveNames());

CertificationManager certificationManager = getPage().getCertificationManager();
List<AccessCertificationCaseType> caseList = certificationManager.searchDecisions(campaignQuery, caseQuery, reviewerOid, notDecidedOnly, resolveNames, task, result);
List<AccessCertificationCaseType> caseList = certificationManager.searchDecisions(caseQuery, reviewerOid, notDecidedOnly, resolveNames, task, result);

for (AccessCertificationCaseType _case : caseList) {
getAvailableData().add(new CertDecisionDto(_case, getPage()));
Expand Down Expand Up @@ -114,7 +114,7 @@ protected int internalSize() {
CertificationManager certificationManager = getPage().getCertificationManager();
ObjectQuery query = getQuery().clone();
query.setPaging(null); // when counting decisions we need to exclude offset+size (and sorting info is irrelevant)
List<AccessCertificationCaseType> caseList = certificationManager.searchDecisions(campaignQuery, query, reviewerOid, notDecidedOnly, null, task, result);
List<AccessCertificationCaseType> caseList = certificationManager.searchDecisions(query, reviewerOid, notDecidedOnly, null, task, result);
count = caseList.size();
} catch (Exception ex) {
result.recordFatalError("Couldn't count objects.", ex);
Expand Down
Expand Up @@ -20,25 +20,21 @@
import java.util.Collection;
import java.util.Iterator;

import javax.xml.namespace.QName;

import org.apache.commons.lang.StringUtils;

import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.Objectable;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.SchemaException;

public class InOidFilter extends ObjectFilter {

private Collection<String> oids;
private ExpressionWrapper expression;
private boolean considerOwner; // temporary hack (checks owner OID)

InOidFilter(Collection<String> oids) {
InOidFilter(boolean considerOwner, Collection<String> oids) {
this.considerOwner = considerOwner;
this.oids = oids;
}

Expand All @@ -47,13 +43,21 @@ public class InOidFilter extends ObjectFilter {
}

public static InOidFilter createInOid(Collection<String> oids){
return new InOidFilter(oids);
return new InOidFilter(false, oids);
}

public static InOidFilter createInOid(String... oids){
return new InOidFilter(Arrays.asList(oids));
return new InOidFilter(false, Arrays.asList(oids));
}


public static InOidFilter createOwnerHasOidIn(Collection<String> oids){
return new InOidFilter(true, oids);
}

public static InOidFilter createOwnerHasOidIn(String... oids){
return new InOidFilter(true, Arrays.asList(oids));
}

public static InOidFilter createInOid(ExpressionWrapper expression){
return new InOidFilter(expression);
}
Expand All @@ -65,7 +69,11 @@ public Collection<String> getOids() {
public void setOids(Collection<String> oids) {
this.oids = oids;
}


public boolean isConsiderOwner() {
return considerOwner;
}

public ExpressionWrapper getExpression() {
return expression;
}
Expand All @@ -74,8 +82,6 @@ public void setExpression(ExpressionWrapper expression) {
this.expression = expression;
}



@Override
public void checkConsistence() {
if (oids == null) {
Expand All @@ -97,22 +103,21 @@ public String debugDump() {
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
sb.append("IN OID: ");


sb.append("\n");
DebugUtil.indentDebugDump(sb, indent+1);
if (considerOwner) {
sb.append("(for owner)");
}
sb.append("VALUE:");
if (getOids() != null) {
sb.append("\n");
for (String oid : getOids()) {
DebugUtil.indentDebugDump(sb, indent+1);
sb.append(oid);
sb.append("\n");
}
} else {
sb.append(" null");
sb.append(" null\n");
}


return sb.toString();

}
Expand All @@ -139,7 +144,7 @@ public String toString() {

@Override
public InOidFilter clone() {
InOidFilter inOid = new InOidFilter(getOids());
InOidFilter inOid = new InOidFilter(considerOwner, getOids());
inOid.setExpression(getExpression());
return inOid;
}
Expand Down
Expand Up @@ -36,12 +36,17 @@ protected ObjectPaging() {
// TODO Auto-generated constructor stub
}

ObjectPaging(Integer offset, Integer maxSize){
ObjectPaging(Integer offset, Integer maxSize) {
this.offset = offset;
this.maxSize = maxSize;
}

ObjectPaging(Integer offset, Integer maxSize, ItemPath orderBy, OrderDirection direction){
public ObjectPaging(ItemPath orderBy, OrderDirection direction) {
this.orderBy = orderBy;
this.direction = direction;
}

ObjectPaging(Integer offset, Integer maxSize, ItemPath orderBy, OrderDirection direction) {
this.offset = offset;
this.maxSize = maxSize;
this.orderBy = orderBy;
Expand All @@ -63,6 +68,10 @@ public static ObjectPaging createPaging(Integer offset, Integer maxSize, ItemPat
public static ObjectPaging createPaging(Integer offset, Integer maxSize, String orderBy, String namespace, OrderDirection direction){
return createPaging(offset, maxSize, new QName(namespace, orderBy), direction);
}

public static ObjectPaging createPaging(ItemPath orderBy, OrderDirection direction) {
return new ObjectPaging(orderBy, direction);
}

public static ObjectPaging createEmptyPaging(){
return new ObjectPaging();
Expand Down
Expand Up @@ -12733,7 +12733,7 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>-->
<xsd:element name="enabled" type="xsd:boolean" minOccurs="0" maxOccurs="1">
<xsd:element name="enabled" type="xsd:boolean" minOccurs="1" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Is the case enabled for the current stage? E.g. cases that have been marked as "remove" in a given stage
Expand Down
Expand Up @@ -87,8 +87,7 @@ AccessCertificationCampaignType createCampaign(AccessCertificationDefinitionType
* depending on the certification definition (scope and handler). In all stages, reviewers will be assigned
* to cases, based again on the definition (reviewer specification in stage definition and handler).
*
* @param campaign Certification campaign. If its definition reference is already resolved, it will be used.
* Otherwise, the implementation will resolve the definition by itself.
* @param campaignOid Certification campaign OID.
* @param stageNumber Stage that has to be open. This has to be the stage after the current one (or the first one).
* @param task Task in context of which all operations will take place.
* @param parentResult Result for the operations.
Expand All @@ -102,8 +101,7 @@ AccessCertificationCampaignType createCampaign(AccessCertificationDefinitionType
* depending on the certification definition (scope and handler). In all stages, reviewers will be assigned
* to cases, based again on the definition (reviewer specification in stage definition and handler).
*
* @param campaign Certification campaign. If its definition reference is already resolved, it will be used.
* Otherwise, the implementation will resolve the definition by itself.
* @param campaignOid Certification campaign OID.
* @param stageNumber Stage that has to be closed. This has to be the current stage.
* @param task Task in context of which all operations will take place.
* @param parentResult Result for the operations.
Expand All @@ -114,7 +112,7 @@ AccessCertificationCampaignType createCampaign(AccessCertificationDefinitionType
* Starts the remediation phase for the campaign.
* The campaign has to be in the last stage and that stage has to be already closed.
*
* @param campaign
* @param campaignOid
* @param task
* @param result
*/
Expand All @@ -123,7 +121,7 @@ AccessCertificationCampaignType createCampaign(AccessCertificationDefinitionType
/**
* Closes a campaign.
*
* @param campaign
* @param campaignOid
* @param task
* @param result
*/
Expand All @@ -140,7 +138,7 @@ AccessCertificationCampaignType createCampaign(AccessCertificationDefinitionType
* - name of object, by setting paging.orderBy = objectRef
* - name of target, by setting paging.orderBy = targetRef
* Note that in order to use names as a sorting criteria, it is necessary to include RESOLVE_NAMES option in the operation call.
* Paging is specified by offset (counting from 0) and maxSize. Paging cooke is ignored.
* Paging is specified by offset (counting from 0) and maxSize. Paging cookie is ignored.
*
* NOTE THAT THE SORTING INTERFACE WILL PROBABLY BE CHANGED IN NEAR FUTURE.
*
Expand Down Expand Up @@ -175,8 +173,7 @@ AccessCertificationCampaignType createCampaign(AccessCertificationDefinitionType
* - name of campaign, by setting paging.orderBy = campaignRef
* - deadline or reviewRequestedTimestamp, by setting paging.orderBy = reviewDeadline/reviewRequestedTimestamp
*
* @param campaignQuery Specification of campaigns to query.
* @param caseQuery Specification of the cases to retrieve.
* @param caseQuery Specification of the cases to retrieve. (In future it may contain restrictions on owning campaign(s).)
* @param reviewerOid OID of the reviewer whose decisions we want to retrieve.
* @param notDecidedOnly If true, only response==(NO_DECISION or null) should be returned.
* It is currently not possible to formulate this using Query API
Expand All @@ -185,9 +182,10 @@ AccessCertificationCampaignType createCampaign(AccessCertificationDefinitionType
* @param task Task in context of which all operations will take place.
* @param parentResult Result for the operations.
* @return A list of relevant certification cases.
*
*/

List<AccessCertificationCaseType> searchDecisions(ObjectQuery campaignQuery, ObjectQuery caseQuery,
List<AccessCertificationCaseType> searchDecisions(ObjectQuery caseQuery,
String reviewerOid, boolean notDecidedOnly,
Collection<SelectorOptions<GetOperationOptions>> options,
Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, CommunicationException;
Expand Down
Expand Up @@ -95,9 +95,9 @@ public void onReviewDeadlineApproaching(ObjectReferenceType reviewerRef, List<Ac
}
}

public Collection<String> getCurrentReviewers(AccessCertificationCampaignType campaign) {
public Collection<String> getCurrentReviewers(List<AccessCertificationCaseType> caseList) {
Set<String> oids = new HashSet<>();
for (AccessCertificationCaseType aCase : campaign.getCase()) {
for (AccessCertificationCaseType aCase : caseList) {
if (Boolean.TRUE.equals(aCase.isEnabled())) {
for (ObjectReferenceType reviewerRef : aCase.getReviewerRef()) {
oids.add(reviewerRef.getOid());
Expand All @@ -107,18 +107,4 @@ public Collection<String> getCurrentReviewers(AccessCertificationCampaignType ca
return oids;
}

public List<AccessCertificationCaseType> getCasesForReviewer(AccessCertificationCampaignType campaign, String oid) {
List<AccessCertificationCaseType> rv = new ArrayList<>();
for (AccessCertificationCaseType aCase : campaign.getCase()) {
if (Boolean.TRUE.equals(aCase.isEnabled())) {
for (ObjectReferenceType reviewerRef : aCase.getReviewerRef()) {
if (oid.equals(reviewerRef.getOid())) {
rv.add(aCase.clone());
break;
}
}
}
}
return rv;
}
}

0 comments on commit 393fe6b

Please sign in to comment.