2 Commits

Author SHA1 Message Date
Wanja Krah
e617bc09c1 WIP: verder uitbreiden model 2025-05-22 18:42:39 +02:00
Wanja Krah
aa6f50e3c8 set basis and model 2025-05-15 18:38:36 +02:00
27 changed files with 768 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.iml
.idea
target

3
.mvn/maven.config Normal file
View File

@@ -0,0 +1,3 @@
-s.mvn\settings-local.xml
-Dmaven.repo.local=D:\workspace\private\.m2repo

265
.mvn/settings-local.xml Normal file
View File

@@ -0,0 +1,265 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| users on a machine (assuming they're all using the same Maven
| installation). It's normally provided in
| ${maven.conf}/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -gs /path/to/global/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
-->
<!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
-->
<!-- pluginGroups
| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<!-- TODO Since when can proxies be selected as depicted? -->
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<!-- server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
-->
<!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers>
<!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
</mirrors>
<!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<!--
| Here is another profile, activated by the property 'target-env' with a value of 'dev', which
| provides a specific path to the Tomcat instance. To use this, your plugin configuration might
| hypothetically look like:
|
| ...
| <plugin>
| <groupId>org.myco.myplugins</groupId>
| <artifactId>myplugin</artifactId>
|
| <configuration>
| <tomcatLocation>${tomcatPath}</tomcatLocation>
| </configuration>
| </plugin>
| ...
|
| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
| anything, you could just leave off the <value/> inside the activation-property.
|
<profile>
<id>env-dev</id>
<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
</settings>

36
agiledancers-be/pom.xml Normal file
View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.agilecc.agiledancers</groupId>
<artifactId>agiledancers</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>agiledancers-be</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.google.ortools</groupId>
<artifactId>ortools-java</artifactId>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>net.datafaker</groupId>
<artifactId>datafaker</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,30 @@
package nl.agilecc.agiledancers.model;
import lombok.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@Getter
@Setter
@EqualsAndHashCode
@ToString
@NoArgsConstructor
public abstract class AbstractEntity {
private Long id;
protected <T> void addNullSafe(Set<T> set, T t) {
emptyIfNull(set).add(t);
}
private <T> Set<T> emptyIfNull(Set<T> set) {
return set == null ?
new HashSet<>() :
set;
}
protected <T> Set<T> unmodifiableNullSafe(Set<T> set) {
return set == null ? Collections.emptySet() : Collections.unmodifiableSet(set);
}
}

View File

@@ -0,0 +1,12 @@
package nl.agilecc.agiledancers.model;
import lombok.*;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@ToString(onlyExplicitlyIncluded = true)
public class Coach extends AbstractEntity {
@ToString.Include
private final String name;
}

View File

@@ -0,0 +1,46 @@
package nl.agilecc.agiledancers.model;
import lombok.*;
import nl.agilecc.agiledancers.model.specifications.DanceGroupStyle;
import nl.agilecc.agiledancers.model.specifications.DanceGroupType;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@ToString(onlyExplicitlyIncluded = true)
public class DanceGroup extends AbstractEntity {
@ToString.Include
private final String category;
@ToString.Include
private final DanceGroupType type;
@ToString.Include
private final int startAge;
@ToString.Include
private final int endAge;
@ToString.Include
private Set<Dancer> dancers;
@ToString.Include
private Set<DanceGroupStyle> styles;
@ToString.Include
private Coach coach;
public Set<Dancer> getDancers() {
return super.unmodifiableNullSafe(dancers);
}
public void addDancer(Dancer dancer) {
super.addNullSafe(dancers, dancer);
}
public Set<DanceGroupStyle> getStyles() {
return super.unmodifiableNullSafe(styles);
}
public void addStyle(DanceGroupStyle style) {
super.addNullSafe(styles, style);
}
}

View File

@@ -0,0 +1,50 @@
package nl.agilecc.agiledancers.model;
import lombok.*;
import java.util.Collections;
import java.util.Set;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@ToString(onlyExplicitlyIncluded = true)
public class DanceSchool extends AbstractEntity {
private final String name;
private final Set<Dancer> dancers;
private final Set<DanceGroup> danceGroups;
private final Set<Show> shows;
private final Set<Coach> coaches;
public Set<Dancer> getDancers() {
return super.unmodifiableNullSafe(dancers);
}
public Set<DanceGroup> getDanceGroups() {
return super.unmodifiableNullSafe(danceGroups);
}
public Set<Show> getShows() {
return super.unmodifiableNullSafe(shows);
}
public Set<Coach> getCoaches() {
return super.unmodifiableNullSafe(coaches);
}
public void addDancer(Dancer dancer) {
super.addNullSafe(dancers, dancer);
}
public void addDanceGroup(DanceGroup danceGroup) {
super.addNullSafe(danceGroups, danceGroup);
}
public void addShow(Show show) {
super.addNullSafe(shows, show);
}
public void addCoach(Coach coach) {
super.addNullSafe(coaches, coach);
}
}

View File

@@ -0,0 +1,21 @@
package nl.agilecc.agiledancers.model;
import lombok.*;
import java.time.LocalDate;
import java.time.Period;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@ToString(onlyExplicitlyIncluded = true)
public class Dancer extends AbstractEntity {
@ToString.Include
private final String name;
@ToString.Include
private LocalDate birthDate;
public int age() {
return Period.between(birthDate, LocalDate.now()).getYears();
}
}

View File

@@ -0,0 +1,17 @@
package nl.agilecc.agiledancers.model;
import lombok.*;
import nl.agilecc.agiledancers.model.specifications.DayPartType;
import java.util.List;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@ToString(onlyExplicitlyIncluded = true)
public class DayPart extends AbstractEntity {
@ToString.Include
private final DayPartType type;
@ToString.Include
private final List<DanceGroup> danceGroups;
}

View File

@@ -0,0 +1,14 @@
package nl.agilecc.agiledancers.model;
import lombok.*;
import java.util.List;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@ToString(onlyExplicitlyIncluded = true)
public class Show extends AbstractEntity {
@ToString.Include
private final List<DayPart> dayParts;
}

View File

@@ -0,0 +1,5 @@
package nl.agilecc.agiledancers.model.specifications;
public enum DanceGroupStyle {
HIPHOP, JAZZ, MODERN, STREETDANCE, CLASSIC, BREAKDANCE
}

View File

@@ -0,0 +1,18 @@
package nl.agilecc.agiledancers.model.specifications;
import lombok.Getter;
public enum DanceGroupType {
SHOW_CASE(3),
PRE_EDUCATION(1), // TODO check if this is one group mentioned with different docent each time, or three different groups - and thus if they are required 1 day or 3
SELECTION(2),
REGULAR(2),
PRE_SCHOOLER(1);
@Getter
private int dayPartsRequired;
DanceGroupType(int dayPartsRequired) {
this.dayPartsRequired = dayPartsRequired;
}
}

View File

@@ -0,0 +1,5 @@
package nl.agilecc.agiledancers.model.specifications;
public enum DayPartType {
MORNING, AFTERNOON, EVENING;
}

View File

@@ -0,0 +1,27 @@
package nl.agilecc.agiledancers.repository;
import nl.agilecc.agiledancers.model.AbstractEntity;
import java.util.*;
public abstract class AbstractRepository<T extends AbstractEntity> {
private long sequence = 0L;
protected Map<Long, T> entities = new LinkedHashMap<>();
public T add(T entity) {
if (entity.getId() == null) {
entity.setId(sequence++);
}
entities.put(entity.getId(), entity);
return entity;
}
public List<T> findAll() {
return List.copyOf(entities.values());
}
public T findById(long id) {
return entities.get(id);
}
}

View File

@@ -0,0 +1,7 @@
package nl.agilecc.agiledancers.repository;
import nl.agilecc.agiledancers.model.Coach;
public class CoachRepository extends AbstractRepository<Coach> {
}

View File

@@ -0,0 +1,6 @@
package nl.agilecc.agiledancers.repository;
import nl.agilecc.agiledancers.model.DanceGroup;
public class DanceGroupRepository extends AbstractRepository<DanceGroup> {
}

View File

@@ -0,0 +1,6 @@
package nl.agilecc.agiledancers.repository;
import nl.agilecc.agiledancers.model.DanceSchool;
public class DanceSchoolRepository extends AbstractRepository<DanceSchool> {
}

View File

@@ -0,0 +1,6 @@
package nl.agilecc.agiledancers.repository;
import nl.agilecc.agiledancers.model.Dancer;
public class DancerRepository extends AbstractRepository<Dancer> {
}

View File

@@ -0,0 +1,6 @@
package nl.agilecc.agiledancers.repository;
import nl.agilecc.agiledancers.model.DayPart;
public class DayPartRepository extends AbstractRepository<DayPart> {
}

View File

@@ -0,0 +1,6 @@
package nl.agilecc.agiledancers.repository;
import nl.agilecc.agiledancers.model.Show;
public class ShowRepository extends AbstractRepository<Show> {
}

View File

@@ -0,0 +1,12 @@
package nl.agilecc.agiledancers.service;
import nl.agilecc.agiledancers.model.Coach;
import nl.agilecc.agiledancers.repository.CoachRepository;
public class CoachService {
private CoachRepository coachRepository = new CoachRepository();
public Coach addCoach(String name, Coach coach) {
return coachRepository.add(Coach.builder().name(name).build());
}
}

View File

@@ -0,0 +1,27 @@
package nl.agilecc.agiledancers.service;
import nl.agilecc.agiledancers.model.Coach;
import nl.agilecc.agiledancers.model.DanceGroup;
import nl.agilecc.agiledancers.model.Dancer;
import nl.agilecc.agiledancers.model.specifications.DanceGroupStyle;
import nl.agilecc.agiledancers.model.specifications.DanceGroupType;
import nl.agilecc.agiledancers.repository.DanceGroupRepository;
import java.util.Set;
public class DanceGroupService {
private final DanceGroupRepository danceGroupRepository = new DanceGroupRepository();
public DanceGroup add(String category, DanceGroupType type, int startAge, int endAge, Set<Dancer> dancers, Set<DanceGroupStyle> styles, Coach coach) {
DanceGroup danceGroup = DanceGroup.builder()
.category(category)
.type(type)
.startAge(startAge)
.endAge(endAge)
.dancers(dancers)
.styles(styles)
.coach(coach).build();
return danceGroupRepository.add(danceGroup);
}
}

View File

@@ -0,0 +1,29 @@
package nl.agilecc.agiledancers.service;
import nl.agilecc.agiledancers.model.*;
import nl.agilecc.agiledancers.repository.DanceSchoolRepository;
public class DanceSchoolService {
private final DanceSchoolRepository danceSchoolRepository = new DanceSchoolRepository();
public DanceSchool add(String name) {
DanceSchool danceSchool = DanceSchool.builder().name(name).build();
return danceSchoolRepository.add(danceSchool);
}
public void addDancer(Long danceSchoolId, Dancer dancer) {
danceSchoolRepository.findById(danceSchoolId).addDancer(dancer);
}
public void addDanceGroup(Long danceSchoolId, DanceGroup danceGroup) {
danceSchoolRepository.findById(danceSchoolId).addDanceGroup(danceGroup);
}
public void addCoach(Long danceSchoolId, Coach coach) {
danceSchoolRepository.findById(danceSchoolId).addCoach(coach);
}
public void addShow(Long danceSchoolId, Show show) {
danceSchoolRepository.findById(danceSchoolId).addShow(show);
}
}

View File

@@ -0,0 +1,15 @@
package nl.agilecc.agiledancers.service;
import nl.agilecc.agiledancers.model.Dancer;
import nl.agilecc.agiledancers.repository.DancerRepository;
import java.time.LocalDate;
public class DancerService {
private final DancerRepository dancerRepository = new DancerRepository();
public Dancer addDancer(String name, LocalDate birthDate) {
Dancer dancer = Dancer.builder().name(name).birthDate(birthDate).build();
return dancerRepository.add(dancer);
}
}

View File

@@ -0,0 +1,26 @@
package sit;
import net.datafaker.Faker;
import nl.agilecc.agiledancers.model.DanceSchool;
import nl.agilecc.agiledancers.service.DanceSchoolService;
import org.junit.jupiter.api.Test;
class DanceSchoolSit {
Faker faker = new Faker();
int numberOfDanceGroups = 42;
int aantalDansersTm5 = 10;
int aantalDansers6tm10 = 30;
int aantalDansers11tot14 = 70;
int aantalDansers14tm17 = 140;
int aantalDansers18Plus = 100;
private DanceSchoolService danceSchoolService = new DanceSchoolService();
@Test
void testDanceSchoolModel() {
DanceSchool danceSchool = danceSchoolService.add("24 Dance Studio");
}
}

70
pom.xml Normal file
View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.agilecc.agiledancers</groupId>
<artifactId>agiledancers</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Agile Dancers</name>
<description>To map multiple dance groups to multiple dance performance dayparts with respect to certain constraints.</description>
<modules>
<module>agiledancers-be</module>
</modules>
<!-- TODO Add SCM ??? -->
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<ortools-java.version>9.12.4544</ortools-java.version>
<lombok.version>1.18.38</lombok.version>
<!-- test dependencies -->
<datafaker.version>2.4.3</datafaker.version>
<junit-jupiter.version>5.12.2</junit-jupiter.version>
</properties>
<!-- dependencies that can be included by child-project - without stating the version -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.ortools</groupId>
<artifactId>ortools-java</artifactId>
<version>${ortools-java.version}</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>net.datafaker</groupId>
<artifactId>datafaker</artifactId>
<version>${datafaker.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- dependencies that will always be included by the child-project -->
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
</project>