use of io.lumeer.api.model.CollectionPurpose in project engine by Lumeer.
the class CollectionFacade method deleteCollectionAttribute.
public void deleteCollectionAttribute(final String collectionId, final String attributeId) {
final Collection collection = collectionDao.getCollectionById(collectionId);
final Collection originalCollection = collection.copy();
permissionsChecker.checkRole(collection, RoleType.AttributeEdit);
dataDao.deleteAttribute(collectionId, attributeId);
collection.deleteAttribute(attributeId);
if (collection.getDefaultAttributeId() != null && collection.getDefaultAttributeId().equals(attributeId)) {
collection.setDefaultAttributeId(null);
}
final CollectionPurpose purpose = collection.getPurpose();
if (attributeId.equals(purpose.getStateAttributeId())) {
purpose.clearStateAttributeId();
}
if (attributeId.equals(purpose.getDueDateAttributeId())) {
purpose.clearDueDateAttributeId();
}
if (attributeId.equals(purpose.getAssigneeAttributeId())) {
purpose.clearAssigneeAttributeId();
}
if (attributeId.equals(purpose.getObserverAttributeId())) {
purpose.clearObserverAttributeId();
purpose.clearFinalStatesList();
}
collection.setLastTimeUsed(ZonedDateTime.now());
mapResourceUpdateValues(collection);
filterAutoLinkRulesByAttribute(collection, collectionId, attributeId);
collectionDao.updateCollection(collection.getId(), collection, originalCollection);
deleteAutoLinkRulesByAttribute(collectionId, attributeId);
fileAttachmentFacade.removeAllFileAttachments(collectionId, attributeId, FileAttachment.AttachmentType.DOCUMENT);
}
use of io.lumeer.api.model.CollectionPurpose in project engine by Lumeer.
the class DocumentFacadeIT method configureCollection.
@Before
public void configureCollection() {
User user = new User(USER);
this.user = userDao.createUser(user);
Organization organization = new Organization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new Permissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
groupDao.setOrganization(storedOrganization);
group = groupDao.createGroup(new Group(GROUP, Collections.singletonList(user.getId())));
user.setOrganizations(Collections.singleton(storedOrganization.getId()));
this.user = userDao.updateUser(user.getId(), user);
Permissions organizationPermissions = new Permissions();
Permission userPermission = Permission.buildWithRoles(this.user.getId(), Collections.singleton(new Role(RoleType.Read)));
organizationPermissions.updateUserPermissions(userPermission);
storedOrganization.setPermissions(organizationPermissions);
organizationDao.updateOrganization(storedOrganization.getId(), storedOrganization);
Project project = new Project();
project.setCode(PROJECT_CODE);
Permissions projectPermissions = new Permissions();
projectPermissions.updateUserPermissions(userPermission);
project.setPermissions(projectPermissions);
Project storedProject = projectDao.createProject(project);
workspaceKeeper.setWorkspaceIds(storedOrganization.getId(), storedProject.getId());
collectionDao.setProject(storedProject);
collectionDao.createRepository(storedProject);
Permissions collectionPermissions = new Permissions();
collectionPermissions.updateUserPermissions(new Permission(this.user.getId(), Collections.singleton(new Role(RoleType.Read))));
Collection collection = new Collection("123456789", COLLECTION_NAME, COLLECTION_ICON, COLLECTION_COLOR, collectionPermissions);
collection.setLastAttributeNum(0);
this.collection = collectionDao.createCollection(collection);
Collection taskCollection = new Collection("abcdefghi", COLLECTION_NAME + "_task", COLLECTION_ICON, COLLECTION_COLOR, collectionPermissions);
DataDocument purposeMetadata = new DataDocument(CollectionPurpose.META_ASSIGNEE_ATTRIBUTE_ID, KEY1);
CollectionPurpose taskPurpose = new CollectionPurpose(CollectionPurposeType.Tasks, purposeMetadata);
taskCollection.setPurpose(taskPurpose);
taskCollection.setLastAttributeNum(0);
taskCollection.setAttributes(Collections.singleton(new Attribute(KEY1)));
this.taskCollection = collectionDao.createCollection(taskCollection);
permissionsChecker.getPermissionAdapter().invalidateUserCache();
}
Aggregations