mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-3376 GET rule order within rule set.
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.impl.rules;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import static org.alfresco.rest.api.model.rules.InclusionType.INHERITED;
|
||||
import static org.alfresco.rest.api.model.rules.InclusionType.LINKED;
|
||||
import static org.alfresco.rest.api.model.rules.InclusionType.OWNED;
|
||||
@@ -32,6 +34,8 @@ import static org.alfresco.rest.api.model.rules.InclusionType.OWNED;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.rest.api.impl.mapper.rules.RestRuleModelMapper;
|
||||
import org.alfresco.rest.api.model.rules.Rule;
|
||||
import org.alfresco.rest.api.model.rules.RuleSet;
|
||||
import org.alfresco.service.Experimental;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -49,9 +53,11 @@ public class RuleSetLoader
|
||||
protected static final String LINKED_TO_BY = "linkedToBy";
|
||||
protected static final String IS_INHERITED = "isInherited";
|
||||
protected static final String IS_LINKED_TO = "isLinkedTo";
|
||||
protected static final String RULE_IDS = "ruleIds";
|
||||
private static final int MAX_INHERITED_BY_SIZE = 100;
|
||||
private NodeService nodeService;
|
||||
private RuleService ruleService;
|
||||
private RestRuleModelMapper restRuleModelMapper;
|
||||
|
||||
/**
|
||||
* Load a rule set for the given node ref.
|
||||
@@ -103,6 +109,10 @@ public class RuleSetLoader
|
||||
{
|
||||
ruleSet.setIsLinkedTo(loadIsLinkedTo(ruleSetNodeRef, parentRef));
|
||||
}
|
||||
if (includes.contains(RULE_IDS))
|
||||
{
|
||||
ruleSet.setRuleIds(loadRuleIds(parentRef));
|
||||
}
|
||||
}
|
||||
return ruleSet;
|
||||
}
|
||||
@@ -139,6 +149,14 @@ public class RuleSetLoader
|
||||
);
|
||||
}
|
||||
|
||||
private List<String> loadRuleIds(NodeRef folderNodeRef)
|
||||
{
|
||||
return ruleService.getRules(folderNodeRef, false).stream()
|
||||
.map(restRuleModelMapper::toRestModel)
|
||||
.map(Rule::getId)
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -148,4 +166,9 @@ public class RuleSetLoader
|
||||
{
|
||||
this.ruleService = ruleService;
|
||||
}
|
||||
|
||||
public void setRestRuleModelMapper(RestRuleModelMapper restRuleModelMapper)
|
||||
{
|
||||
this.restRuleModelMapper = restRuleModelMapper;
|
||||
}
|
||||
}
|
||||
|
@@ -45,6 +45,7 @@ public class RuleSet
|
||||
private List<NodeRef> linkedToBy;
|
||||
private Boolean isInherited;
|
||||
private Boolean isLinkedTo;
|
||||
private List<String> ruleIds;
|
||||
|
||||
public static RuleSet of(String id)
|
||||
{
|
||||
@@ -151,6 +152,16 @@ public class RuleSet
|
||||
return isLinkedTo;
|
||||
}
|
||||
|
||||
public List<String> getRuleIds()
|
||||
{
|
||||
return ruleIds;
|
||||
}
|
||||
|
||||
public void setRuleIds(List<String> ruleIds)
|
||||
{
|
||||
this.ruleIds = ruleIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -163,6 +174,7 @@ public class RuleSet
|
||||
.add("linkedToBy='" + linkedToBy + "'")
|
||||
.add("isInherited='" + isInherited + "'")
|
||||
.add("isLinkedTo='" + isLinkedTo + "'")
|
||||
.add("ruleIds='" + ruleIds + "'")
|
||||
.toString()
|
||||
+ '}';
|
||||
}
|
||||
@@ -181,13 +193,14 @@ public class RuleSet
|
||||
&& Objects.equals(inheritedBy, ruleSet.inheritedBy)
|
||||
&& Objects.equals(linkedToBy, ruleSet.linkedToBy)
|
||||
&& Objects.equals(isInherited, ruleSet.isInherited)
|
||||
&& Objects.equals(isLinkedTo, ruleSet.isLinkedTo);
|
||||
&& Objects.equals(isLinkedTo, ruleSet.isLinkedTo)
|
||||
&& Objects.equals(ruleIds, ruleSet.ruleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(id, owningFolder, inclusionType, inheritedBy, linkedToBy, isInherited, isLinkedTo);
|
||||
return Objects.hash(id, owningFolder, inclusionType, inheritedBy, linkedToBy, isInherited, isLinkedTo, ruleIds);
|
||||
}
|
||||
|
||||
public static Builder builder()
|
||||
@@ -204,6 +217,7 @@ public class RuleSet
|
||||
private List<NodeRef> linkedToBy;
|
||||
private Boolean isInherited;
|
||||
private Boolean isLinkedTo;
|
||||
private List<String> ruleIds;
|
||||
|
||||
public Builder id(String id)
|
||||
{
|
||||
@@ -247,6 +261,12 @@ public class RuleSet
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ruleIds(List<String> ruleIds)
|
||||
{
|
||||
this.ruleIds = ruleIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RuleSet create()
|
||||
{
|
||||
final RuleSet ruleSet = new RuleSet();
|
||||
@@ -257,6 +277,7 @@ public class RuleSet
|
||||
ruleSet.setLinkedToBy(linkedToBy);
|
||||
ruleSet.setIsInherited(isInherited);
|
||||
ruleSet.setIsLinkedTo(isLinkedTo);
|
||||
ruleSet.setRuleIds(ruleIds);
|
||||
return ruleSet;
|
||||
}
|
||||
}
|
||||
|
@@ -864,6 +864,7 @@
|
||||
<bean id="ruleSetLoader" class="org.alfresco.rest.api.impl.rules.RuleSetLoader">
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="ruleService" ref="RuleService" />
|
||||
<property name="restRuleModelMapper" ref="ruleMapper" />
|
||||
</bean>
|
||||
|
||||
<bean id="ruleSets" class="org.alfresco.rest.api.impl.rules.RuleSetsImpl">
|
||||
|
Reference in New Issue
Block a user