Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: filter by aspect #3

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<groupId>org.redpill-linpro.alfresco.numbering</groupId>
<artifactId>alfresco-numbering</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
<name>Alfresco Numbering</name>
<packaging>pom</packaging>
<properties>
Expand Down Expand Up @@ -52,6 +52,18 @@
<url>https://github.com/Redpill-Linpro/alfresco-numbering/issues</url>
</issueManagement>
<repositories>
<repository>
<id>alfresco-public</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>alfresco-public-snapshots</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
<repository>
<id>redpill-public</id>
<url>https://maven.redpill-linpro.com/nexus/content/groups/public</url>
Expand Down
8 changes: 7 additions & 1 deletion repo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.redpill-linpro.alfresco.numbering</groupId>
<artifactId>alfresco-numbering</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<artifactId>alfresco-numbering-repo</artifactId>
<packaging>jar</packaging>
Expand Down Expand Up @@ -55,6 +55,12 @@
<version>1.0.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public class NumberingComponentImpl implements NumberingComponent, InitializingB

protected long startValue = 1;
protected List<String> bindTypes = new ArrayList<>();
protected List<String> bindAspects = new ArrayList<>();
protected List<String> ignoreTypes = new ArrayList<>();
protected List<String> ignoreAspects = new ArrayList<>();
protected List<QName> bindTypeQNames = new ArrayList<>();
protected List<QName> ignoreTypeQNames = new ArrayList<>();
protected List<QName> ignoreAspectQNames = new ArrayList<>();
protected List<QName>bindAspectQNames = new ArrayList<>();
protected Decorator decorator;
protected NamespaceService namespaceService;

Expand Down Expand Up @@ -74,6 +76,21 @@ public boolean allowGetNextNumber(final NodeRef nodeRef) {
return false;
}

// If list bindAspectQNames is not empty, check that the node is of allowed aspect
if (!bindAspectQNames.isEmpty()) {
boolean aspectMatch = false;
for (QName bindAspect : bindAspectQNames) {
if(nodeService.hasAspect(nodeRef, bindAspect)) {
aspectMatch = true;
}
}
if (!aspectMatch) {
if(LOG.isTraceEnabled()) {
LOG.trace("Node " + nodeRef + " is not in the list of allowed aspects ");
}
return false;
}
}
//Check if the node type is on the type ignore list
for (QName ignoreType : ignoreTypeQNames) {
if (type.equals(ignoreType)) {
Expand Down Expand Up @@ -117,7 +134,6 @@ public long getNextNumber(final NodeRef nodeRef,String subOptionValue) {
return numberingStorage.getNextNumber(startValue, id,subOptionValue);
}


@Override
public String getDecoratedNextNumber(final NodeRef nodeRef) {
return decorator.decorate(getNextNumber(nodeRef), nodeRef);
Expand Down Expand Up @@ -179,6 +195,16 @@ public void setBindTypes(List<String> bindTypes) {
}
}

public void setBindAspects(List<String> bindAspects) {
this.bindAspects = bindAspects;
if (bindAspects != null) {
if (LOG.isTraceEnabled()) {
LOG.trace("Registering bind aspects: " + bindAspects.toString());
}
checkForDictionaryExistance(bindAspects, bindAspectQNames);
}
}

public void setIgnoreAspects(List<String> ignoreAspects) {
this.ignoreAspects = ignoreAspects;
if (ignoreAspects != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.redpill.alfresco.numbering.decorator;

import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
* A regular number series
Expand Down