Skip to content

Commit ea17486

Browse files
Merge pull request #547 from Heigvd/dev
instance makers list for models + diverse improvements
2 parents 729a076 + ebf336d commit ea17486

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3632
-2927
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
- challenge
7+
- dev
88
tags:
99
- "v*"
1010
pull_request:
@@ -133,21 +133,3 @@ jobs:
133133
build-args: |
134134
GITHUB_RUN_NUMBER=${{ github.run_number }}
135135
DOCKER_IMAGE_TAGS=${{ steps.docker-meta.outputs.tags }}
136-
137-
update-dev-fleet:
138-
runs-on: ubuntu-latest
139-
needs: build
140-
if: ${{ github.ref == 'refs/heads/main' }}
141-
steps:
142-
- name: Update VERSION.md in colab-dev-fleet
143-
shell: bash
144-
run: |
145-
git clone --single-branch --branch main "https://${{ secrets.ALBASIM_CI_REPO_PAT }}@github.com/Heigvd/colab-dev-fleet.git" colab-dev-fleet
146-
cd colab-dev-fleet
147-
echo "GitHub Build #${GITHUB_RUN_NUMBER}, based on ${GITHUB_REF} @ ${GITHUB_SHA}" > VERSION.md
148-
perl -pi -e "s/(colab\.fleet\.number)=.*$/\1=${GITHUB_RUN_NUMBER}/" fleet.yaml
149-
git config user.email "albasim@heig-vd.ch"
150-
git config user.name "albasim-ci"
151-
git add VERSION.md fleet.yaml
152-
git commit -m "Update version"
153-
git push

colab-api/src/main/java/ch/colabproject/colab/api/controller/DuplicationManager.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,8 @@
1414
import ch.colabproject.colab.api.exceptions.ColabMergeException;
1515
import ch.colabproject.colab.api.model.ColabEntity;
1616
import ch.colabproject.colab.api.model.DuplicationParam;
17-
import ch.colabproject.colab.api.model.card.AbstractCardType;
18-
import ch.colabproject.colab.api.model.card.Card;
19-
import ch.colabproject.colab.api.model.card.CardContent;
20-
import ch.colabproject.colab.api.model.card.CardType;
21-
import ch.colabproject.colab.api.model.card.CardTypeRef;
22-
import ch.colabproject.colab.api.model.document.AbstractResource;
23-
import ch.colabproject.colab.api.model.document.Document;
24-
import ch.colabproject.colab.api.model.document.DocumentFile;
25-
import ch.colabproject.colab.api.model.document.ExternalLink;
26-
import ch.colabproject.colab.api.model.document.LexicalDataOwnershipKind;
27-
import ch.colabproject.colab.api.model.document.Resource;
28-
import ch.colabproject.colab.api.model.document.ResourceRef;
29-
import ch.colabproject.colab.api.model.document.TextDataBlock;
17+
import ch.colabproject.colab.api.model.card.*;
18+
import ch.colabproject.colab.api.model.document.*;
3019
import ch.colabproject.colab.api.model.link.ActivityFlowLink;
3120
import ch.colabproject.colab.api.model.link.StickyNoteLink;
3221
import ch.colabproject.colab.api.model.project.Project;
@@ -36,17 +25,14 @@
3625
import ch.colabproject.colab.api.model.user.User;
3726
import ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage;
3827
import ch.colabproject.colab.generator.model.exceptions.MessageI18nKey;
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
30+
31+
import javax.jcr.RepositoryException;
3932
import java.io.IOException;
4033
import java.io.InputStream;
41-
import java.util.ArrayList;
42-
import java.util.Comparator;
43-
import java.util.HashMap;
44-
import java.util.List;
45-
import java.util.Map;
34+
import java.util.*;
4635
import java.util.Map.Entry;
47-
import javax.jcr.RepositoryException;
48-
import org.slf4j.Logger;
49-
import org.slf4j.LoggerFactory;
5036

5137
/**
5238
* Duplication of colab entities.
@@ -179,6 +165,10 @@ public Project duplicateProject(Project originalProject) {
179165
logger.info("param do not duplicate project's team members");
180166
}
181167

168+
////////////////////////////////////////////////////////////////////////////////////////
169+
// instance makers
170+
/* are never duplicated */
171+
182172
////////////////////////////////////////////////////////////////////////////////////////
183173
// Card types
184174
if (params.isWithCardTypes()) {

colab-api/src/main/java/ch/colabproject/colab/api/controller/project/ProjectManager.java

Lines changed: 6 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,27 @@
2323
import ch.colabproject.colab.api.model.card.CardContent;
2424
import ch.colabproject.colab.api.model.link.ActivityFlowLink;
2525
import ch.colabproject.colab.api.model.project.CopyParam;
26-
import ch.colabproject.colab.api.model.project.InstanceMaker;
2726
import ch.colabproject.colab.api.model.project.Project;
2827
import ch.colabproject.colab.api.model.team.TeamMember;
2928
import ch.colabproject.colab.api.model.team.acl.HierarchicalPosition;
3029
import ch.colabproject.colab.api.model.user.User;
3130
import ch.colabproject.colab.api.persistence.jpa.project.CopyParamDao;
32-
import ch.colabproject.colab.api.persistence.jpa.project.InstanceMakerDao;
3331
import ch.colabproject.colab.api.persistence.jpa.project.ProjectDao;
3432
import ch.colabproject.colab.api.rest.project.bean.ProjectCreationData;
3533
import ch.colabproject.colab.api.rest.project.bean.ProjectStructure;
3634
import ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage;
3735
import ch.colabproject.colab.generator.model.exceptions.MessageI18nKey;
36+
import org.slf4j.Logger;
37+
import org.slf4j.LoggerFactory;
38+
39+
import javax.ejb.LocalBean;
40+
import javax.ejb.Stateless;
41+
import javax.inject.Inject;
3842
import java.util.ArrayList;
3943
import java.util.List;
4044
import java.util.Optional;
4145
import java.util.Set;
4246
import java.util.stream.Collectors;
43-
import javax.ejb.LocalBean;
44-
import javax.ejb.Stateless;
45-
import javax.inject.Inject;
46-
import org.slf4j.Logger;
47-
import org.slf4j.LoggerFactory;
4847

4948
/**
5049
* Project specific logic
@@ -93,12 +92,6 @@ public class ProjectManager {
9392
@Inject
9493
private CopyParamDao copyParamDao;
9594

96-
/**
97-
* Instance maker persistence handler
98-
*/
99-
@Inject
100-
private InstanceMakerDao instanceMakerDao;
101-
10295
/**
10396
* Team specific logic management
10497
*/
@@ -480,78 +473,6 @@ public Project duplicateProject(Long projectId, DuplicationParam params) {
480473
}
481474
}
482475

483-
// *********************************************************************************************
484-
// sharing
485-
// *********************************************************************************************
486-
487-
/**
488-
* Send a token by email to grant access to use the model.
489-
*
490-
* @param modelId the id of the model
491-
* @param email the address to send the sharing token to
492-
*
493-
* @return the pending potential instance maker
494-
*/
495-
public InstanceMaker shareModel(Long modelId, String email) {
496-
logger.debug("Share the model #{} to {}", modelId, email);
497-
Project model = assertAndGetProject(modelId);
498-
499-
return tokenManager.sendModelSharingToken(model, email);
500-
}
501-
502-
/**
503-
* Create an instance maker for the model and the user and then persist it in database
504-
*
505-
* @param user the user
506-
* @param model the model
507-
*
508-
* @return the brand new potential instance maker
509-
*/
510-
public InstanceMaker addAndPersistInstanceMaker(Project model, User user) {
511-
logger.debug("Add and persist instance maker to user {} for model {}", user, model);
512-
513-
InstanceMaker instanceMaker = addInstanceMaker(model, user);
514-
instanceMakerDao.persistInstanceMaker(instanceMaker);
515-
516-
return instanceMaker;
517-
}
518-
519-
/**
520-
* Create an instance maker for the model and the user
521-
*
522-
* @param user the user
523-
* @param model the model
524-
*
525-
* @return the brand new potential instance maker
526-
*/
527-
public InstanceMaker addInstanceMaker(Project model, User user) {
528-
logger.debug("Add instance maker to user {} for model {}", user, model);
529-
530-
if (model != null && user != null
531-
&& findInstanceMakerByProjectAndUser(model, user) != null) {
532-
throw HttpErrorMessage.dataError(MessageI18nKey.DATA_INTEGRITY_FAILURE);
533-
}
534-
535-
InstanceMaker instanceMaker = new InstanceMaker();
536-
537-
instanceMaker.setUser(user);
538-
instanceMaker.setProject(model);
539-
540-
return instanceMaker;
541-
}
542-
543-
/**
544-
* Find the instance maker linked to the given project and the given user.
545-
*
546-
* @param project the project
547-
* @param user the user
548-
*
549-
* @return the matching instance makers
550-
*/
551-
public InstanceMaker findInstanceMakerByProjectAndUser(Project project, User user) {
552-
return instanceMakerDao.findInstanceMakerByProjectAndUser(project, user);
553-
}
554-
555476
// *********************************************************************************************
556477
// retrieve the elements of a project
557478
// *********************************************************************************************
@@ -661,21 +582,6 @@ public Set<ActivityFlowLink> getActivityFlowLinks(Long projectId) {
661582
}).collect(Collectors.toSet());
662583
}
663584

664-
/**
665-
* Get all instance makers linked to the given project.
666-
*
667-
* @param projectId the id of the project
668-
*
669-
* @return all instance makers linked to the project
670-
*/
671-
public List<InstanceMaker> getInstanceMakers(Long projectId) {
672-
logger.debug("Get instance makers of project #{}", projectId);
673-
674-
Project project = assertAndGetProject(projectId);
675-
676-
return instanceMakerDao.findInstanceMakersByProject(project);
677-
}
678-
679585
// *********************************************************************************************
680586
// dedicated to access control
681587
// *********************************************************************************************

0 commit comments

Comments
 (0)