Skip to content

Commit

Permalink
upgrade to causeway 2.0.0-RC4
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbranham committed Mar 25, 2024
1 parent 87bd722 commit fb94120
Show file tree
Hide file tree
Showing 46 changed files with 414 additions and 230 deletions.
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export PROJECT_ROOT := $(shell pwd)

.PHONY: run
run:
@echo "Running the program"
mvn install -DskipTests
mvn -pl webapp spring-boot:run

.PHONY: test
test:
@echo "Running the tests"
mvn test

.PHONY: clean
clean:
@echo "Cleaning the project"
mvn clean
2 changes: 1 addition & 1 deletion module-common-types/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>nexus-command</artifactId>
<groupId>net.savantly</groupId>
<version>2.0.0-RC1</version>
<version>2.0.0-RC4</version>
</parent>

<artifactId>common-types-module</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import org.apache.causeway.applib.annotation.PropertyLayout;
import org.apache.causeway.applib.annotation.Where;


@Property(editing = Editing.ENABLED, maxLength = Notes.MAX_LEN)
@Property(editing = Editing.ENABLED, maxLength = Description.MAX_LEN)
@PropertyLayout(named = "Description", multiLine = 2, hidden = Where.ALL_TABLES)
@Parameter(maxLength = Description.MAX_LEN)
@ParameterLayout(named = "Description", multiLine = 2)
Expand All @@ -24,4 +23,3 @@
int MAX_LEN = 300;

}

2 changes: 1 addition & 1 deletion module-franchise-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>nexus-command</artifactId>
<groupId>net.savantly</groupId>
<version>2.0.0-RC1</version>
<version>2.0.0-RC4</version>
</parent>

<artifactId>module-franchise-tests</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package net.savantly.nexus.franchise.dom.location;


import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.List;

import javax.inject.Inject;
import javax.persistence.RollbackException;

import org.apache.causeway.applib.services.iactnlayer.InteractionService;
import org.apache.causeway.commons.functional.Try;
Expand All @@ -16,14 +14,11 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import lombok.val;
import net.savantly.nexus.franchise.dom.group.FranchiseGroups;
import net.savantly.nexus.franchise.dom.location.FranchiseLocation;
import net.savantly.nexus.franchise.dom.location.FranchiseLocations;
import net.savantly.nexus.franchise.fixture.location.FranchiseLocation_persona;
import net.savantly.nexus.franchise.integtests.OrganizationsModuleIntegTestAbstract;

Expand Down Expand Up @@ -95,22 +90,17 @@ public void whenAlreadyExists() {

MatcherAssert.assertThat(cause,
ThrowableMatchers.causedBy(DuplicateKeyException.class));
// also expect
//MatcherAssert.assertThat(cause,
// ThrowableMatchers.causedBy(DuplicateKeyException.class));
});


// then
assertThat(attempt.isFailure()).isTrue();
val failureIfAny = attempt.getFailure();
assertThat(failureIfAny).isPresent();
assertThat(failureIfAny.get()).isInstanceOf(TransactionSystemException.class);
assertThat(failureIfAny.get().getCause()).isInstanceOf(RollbackException.class);

}

}

@Inject protected InteractionService interactionService;
@Inject
protected InteractionService interactionService;
}
2 changes: 1 addition & 1 deletion module-franchise/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>nexus-command</artifactId>
<groupId>net.savantly</groupId>
<version>2.0.0-RC1</version>
<version>2.0.0-RC4</version>
</parent>

<artifactId>franchise-module</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.causeway.applib.annotation.DomainObject;
import org.apache.causeway.applib.annotation.DomainObjectLayout;
import org.apache.causeway.applib.annotation.Editing;
import org.apache.causeway.applib.annotation.MemberSupport;
import org.apache.causeway.applib.annotation.ParameterLayout;
import org.apache.causeway.applib.annotation.PromptStyle;
import org.apache.causeway.applib.annotation.Property;
Expand Down Expand Up @@ -230,16 +231,7 @@ public void delete() {
repositoryService.removeAndFlush(this);
}

@Action(semantics = SemanticsOf.NON_IDEMPOTENT, commandPublishing = Publishing.ENABLED, executionPublishing = Publishing.ENABLED)
@ActionLayout(associateWith = "members", promptStyle = PromptStyle.DIALOG)
public FranchiseGroup addMember(
@ParameterLayout(named = "User") final OrganizationUser user,
@ParameterLayout(named = "Role") final FranchiseGroupMemberRole role) {
members.add(FranchiseGroupMember.withRequiredFields(this, role, user));
return this;
}


@Action(semantics = SemanticsOf.NON_IDEMPOTENT, commandPublishing = Publishing.ENABLED, executionPublishing = Publishing.ENABLED)
@ActionLayout(associateWith = "members", promptStyle = PromptStyle.DIALOG)
public FranchiseGroup removeMember(
Expand All @@ -249,6 +241,7 @@ public FranchiseGroup removeMember(
});
return this;
}
@MemberSupport
public List<String> choices0RemoveMember() {
return this.getMembers().stream().map(m -> m.getUserName()).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import org.apache.causeway.applib.annotation.Action;
import org.apache.causeway.applib.annotation.ActionLayout;
import org.apache.causeway.applib.annotation.BookmarkPolicy;
import org.apache.causeway.applib.annotation.DomainService;
import org.apache.causeway.applib.annotation.DomainServiceLayout;
import org.apache.causeway.applib.annotation.MemberSupport;
import org.apache.causeway.applib.annotation.MinLength;
import org.apache.causeway.applib.annotation.NatureOfService;
import org.apache.causeway.applib.annotation.PriorityPrecedence;
Expand All @@ -29,18 +29,15 @@
import net.savantly.nexus.organizations.dom.organization.Organization;

@Named(FranchiseModule.NAMESPACE + ".FranchiseGroups")
@DomainService(
nature = NatureOfService.VIEW
)
@DomainService(nature = NatureOfService.VIEW)
@DomainServiceLayout()
@javax.annotation.Priority(PriorityPrecedence.EARLY)
@lombok.RequiredArgsConstructor(onConstructor_ = {@Inject} )
@lombok.RequiredArgsConstructor(onConstructor_ = { @Inject })
public class FranchiseGroups {
final RepositoryService repositoryService;
final JpaSupportService jpaSupportService;
final FranchiseGroupRepository repository;


@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(promptStyle = PromptStyle.DIALOG_SIDEBAR)
public FranchiseGroup create(
Expand All @@ -49,19 +46,19 @@ public FranchiseGroup create(
return repositoryService.persist(FranchiseGroup.withName(organization, name));
}


@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@ActionLayout()
public List<FranchiseGroup> listAll() {
return repository.findAll();
}

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@ActionLayout()
public FranchiseGroup findByName(final FranchiseGroup group) {
return group;
}


@MemberSupport
public Collection<FranchiseGroup> autoComplete0FindByName(@MinLength(1) final String search) {
if (Objects.isNull(search) || "".equals(search)) {
return Collections.emptyList();
Expand All @@ -72,12 +69,12 @@ public Collection<FranchiseGroup> autoComplete0FindByName(@MinLength(1) final St
@Programmatic
public void ping() {
jpaSupportService.getEntityManager(FranchiseLocation.class)
.ifSuccess(entityManager -> {
final TypedQuery<FranchiseGroup> q = entityManager.get().createQuery(
"SELECT p FROM FranchiseGroup p ORDER BY p.name",
FranchiseGroup.class)
.setMaxResults(1);
q.getResultList();
});
.ifSuccess(entityManager -> {
final TypedQuery<FranchiseGroup> q = entityManager.get().createQuery(
"SELECT p FROM FranchiseGroup p ORDER BY p.name",
FranchiseGroup.class)
.setMaxResults(1);
q.getResultList();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public FranchiseLocation removeMember(
found.ifPresent(m -> m.delete());
return this;
}
@MemberSupport
public List<FranchiseLocationMember> choices0RemoveMember() {
return this.members.stream().collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public FranchiseLocationMemberRole create(


@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@ActionLayout()
public List<FranchiseLocationMemberRole> listAll() {
return repository.findAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import org.apache.causeway.applib.annotation.Action;
import org.apache.causeway.applib.annotation.ActionLayout;
import org.apache.causeway.applib.annotation.BookmarkPolicy;
import org.apache.causeway.applib.annotation.DomainService;
import org.apache.causeway.applib.annotation.MemberSupport;
import org.apache.causeway.applib.annotation.MinLength;
import org.apache.causeway.applib.annotation.NatureOfService;
import org.apache.causeway.applib.annotation.Optionality;
Expand All @@ -29,18 +29,15 @@
import net.savantly.nexus.franchise.dom.group.FranchiseGroup;

@Named(FranchiseModule.NAMESPACE + ".FranchiseLocations")
@DomainService(
nature = NatureOfService.VIEW
)
@DomainService(nature = NatureOfService.VIEW)
@javax.annotation.Priority(PriorityPrecedence.EARLY)
@lombok.RequiredArgsConstructor(onConstructor_ = {@Inject} )
@lombok.RequiredArgsConstructor(onConstructor_ = { @Inject })
public class FranchiseLocations {

final RepositoryService repositoryService;
final JpaSupportService jpaSupportService;
final FranchiseLocationRepository repository;


@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(promptStyle = PromptStyle.DIALOG_SIDEBAR)
public FranchiseLocation create(
Expand All @@ -49,42 +46,47 @@ public FranchiseLocation create(
return repositoryService.persist(FranchiseLocation.withRequiredFields(franchisee, name));
}

@MemberSupport
public List<FranchiseGroup> choices0Create() {
return repositoryService.allInstances(FranchiseGroup.class);
}

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@ActionLayout()
public List<FranchiseLocation> listAll() {
return repository.findAll();
}

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@ActionLayout()
public FranchiseLocation findByName(final FranchiseLocation item) {
return item;
}

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
public FranchiseLocation findByNameExact(final String search) {
return repository.findByNameContainingIgnoreCase(search).stream().findFirst().orElse(null);
}

@MemberSupport
public Collection<FranchiseLocation> autoComplete0FindByName(@MinLength(1) final String search) {
if (Objects.isNull(search) || "".equals(search)) {
return Collections.emptyList();
}
return repository.findByNameContainingIgnoreCase(search);
}

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout()
public FranchiseLocation findByNameExact(final String search) {
return repository.findByNameContainingIgnoreCase(search).stream().findFirst().orElse(null);
}

@Programmatic
public void ping() {
jpaSupportService.getEntityManager(FranchiseLocation.class)
.ifSuccess(entityManager -> {
final TypedQuery<FranchiseLocation> q = entityManager.get().createQuery(
"SELECT p FROM FranchiseLocation p ORDER BY p.name",
FranchiseLocation.class)
.setMaxResults(1);
q.getResultList();
});
.ifSuccess(entityManager -> {
final TypedQuery<FranchiseLocation> q = entityManager.get().createQuery(
"SELECT p FROM FranchiseLocation p ORDER BY p.name",
FranchiseLocation.class)
.setMaxResults(1);
q.getResultList();
});
}

}
Loading

0 comments on commit fb94120

Please sign in to comment.