backend rename to OpenCDMP

This commit is contained in:
Efstratios Giannopoulos 2024-04-26 13:50:56 +03:00
parent b18f8ccf9a
commit 3bdace15bb
2383 changed files with 97196 additions and 97210 deletions

62
.gitignore vendored
View File

@ -1,32 +1,32 @@
dmp-frontend/dist.7z dmp-frontend/dist.7z
.idea/ .idea/
*.iml *.iml
dmp-backend/src/main/ui-resources/static/vendor.bundle.js.map backend/src/main/ui-resources/static/vendor.bundle.js.map
dmp-backend/src/main/ui-resources/static/vendor.bundle.js backend/src/main/ui-resources/static/vendor.bundle.js
dmp-backend/src/main/ui-resources/static/unauthorized.module.chunk.js.map backend/src/main/ui-resources/static/unauthorized.module.chunk.js.map
dmp-backend/src/main/ui-resources/static/unauthorized.module.chunk.js backend/src/main/ui-resources/static/unauthorized.module.chunk.js
dmp-backend/src/main/ui-resources/static/styles.bundle.js.map backend/src/main/ui-resources/static/styles.bundle.js.map
dmp-backend/src/main/ui-resources/static/styles.bundle.js backend/src/main/ui-resources/static/styles.bundle.js
dmp-backend/src/main/ui-resources/static/polyfills.bundle.js.map backend/src/main/ui-resources/static/polyfills.bundle.js.map
dmp-backend/src/main/ui-resources/static/polyfills.bundle.js backend/src/main/ui-resources/static/polyfills.bundle.js
dmp-backend/src/main/ui-resources/static/main.bundle.js.map backend/src/main/ui-resources/static/main.bundle.js.map
dmp-backend/src/main/ui-resources/static/main.bundle.js backend/src/main/ui-resources/static/main.bundle.js
dmp-backend/src/main/ui-resources/static/lang/en.json backend/src/main/ui-resources/static/lang/en.json
dmp-backend/src/main/ui-resources/static/inline.bundle.js.map backend/src/main/ui-resources/static/inline.bundle.js.map
dmp-backend/src/main/ui-resources/static/inline.bundle.js backend/src/main/ui-resources/static/inline.bundle.js
dmp-backend/src/main/ui-resources/static/index.html backend/src/main/ui-resources/static/index.html
dmp-backend/src/main/ui-resources/static/favicon.ico backend/src/main/ui-resources/static/favicon.ico
dmp-backend/src/main/ui-resources/static/assets/lang/en.json backend/src/main/ui-resources/static/assets/lang/en.json
dmp-frontend/new 3.xml dmp-frontend/new 3.xml
dmp-backend/src/main/ui-resources/static/ backend/src/main/ui-resources/static/
dmp-backend/web/target/ backend/web/target/
*.class *.class
dmp-backend/web/src/main/ui-resources/static/ backend/web/src/main/ui-resources/static/
dmp-backend/data/target/data-1.0-SNAPSHOT.jar backend/data/target/data-1.0-SNAPSHOT.jar
dmp-backend/data/target/ backend/data/target/
dmp-backend/queryable/target/ backend/queryable/target/
dmp-backend/elastic/target/ backend/elastic/target/
dmp-backend/queryengine/target/ backend/queryengine/target/
*.tar *.tar
*.gz *.gz
final/ final/
@ -38,7 +38,7 @@ dmp-frontend/.vscode/
dmp-frontend/package-lock.json dmp-frontend/package-lock.json
dmp-backend/logging/target/ backend/logging/target/
ELK.Docker/shared/data-elk/ ELK.Docker/shared/data-elk/
# Eclipse # Eclipse
@ -47,12 +47,12 @@ ELK.Docker/shared/data-elk/
bin/ bin/
*.classpath *.classpath
.run .run
openDMP/dmp-backend/uploads/ openDMP/backend/uploads/
openDMP/dmp-backend/tmp/ openDMP/backend/tmp/
logs/ logs/
dmp-backend/web/src/main/resources/certificates/ backend/web/src/main/resources/certificates/
/storage/ /storage/
dmp-backend/target/classes/ backend/target/classes/
dmp-backend/core/target/maven-archiver/ backend/core/target/maven-archiver/
dmp-backend/node_modules/.yarn-integrity backend/node_modules/.yarn-integrity
dmp-frontend/.nx/ dmp-frontend/.nx/

109
backend/core/pom.xml Normal file
View File

@ -0,0 +1,109 @@
<?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>
<artifactId>core</artifactId>
<version>${revision}</version>
<parent>
<groupId>org.opencdmp</groupId>
<artifactId>opencdmp-backend</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<properties>
<java.version>21</java.version>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>1.0.0-SNAPSHOT</revision>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>validation</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>oidc-authz</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>repositorydepositbase</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>common-models</artifactId>
<version>0.0.10</version>
</dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>0.0.14</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>elastic</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>queue-inbox</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>queue-outbox</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>oidc-authn</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>keycloak-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,173 @@
package org.opencdmp.audit;
import gr.cite.tools.logging.EventId;
public class AuditableAction {
public static final EventId DescriptionTemplateType_Query = new EventId(1000, "DescriptionTemplateType_Query");
public static final EventId DescriptionTemplateType_Lookup = new EventId(1001, "DescriptionTemplateType_Lookup");
public static final EventId DescriptionTemplateType_Persist = new EventId(1002, "DescriptionTemplateType_Persist");
public static final EventId DescriptionTemplateType_Delete = new EventId(1003, "DescriptionTemplateType_Delete");
public static final EventId EntityDoi_Query = new EventId(2000, "EntityDoi_Query");
public static final EventId EntityDoi_Lookup = new EventId(2001, "EntityDoi_Lookup");
public static final EventId EntityDoi_Persist = new EventId(2002, "EntityDoi_Persist");
public static final EventId EntityDoi_Delete = new EventId(2003, "EntityDoi_Delete");
public static final EventId DmpBlueprint_Query = new EventId(3000, "DmpBlueprint_Query");
public static final EventId DmpBlueprint_Lookup = new EventId(3001, "DmpBlueprint_Lookup");
public static final EventId DmpBlueprint_Persist = new EventId(3002, "DmpBlueprint_Persist");
public static final EventId DmpBlueprint_Delete = new EventId(3003, "DmpBlueprint_Delete");
public static final EventId DmpBlueprint_Clone = new EventId(3004, "DmpBlueprint_Clone");
public static final EventId DmpBlueprint_PersistNewVersion = new EventId(3005, "DmpBlueprint_PersistNewVersion");
public static final EventId DmpBlueprint_GetXml = new EventId(3006, "DmpBlueprint_GetXml");
public static final EventId DmpBlueprint_Import = new EventId(3007, "DmpBlueprint_Import");
public static final EventId User_Settings_Query = new EventId(4000, "User_Settings_Query");
public static final EventId User_Settings_Lookup = new EventId(4001, "User_Settings_Lookup");
public static final EventId User_Settings_Persist = new EventId(4002, "User_Settings_Persist");
public static final EventId User_Settings_Delete = new EventId(4003, "User_Settings_Delete");
public static final EventId Dmp_Query = new EventId(5000, "Dmp_Query");
public static final EventId Dmp_Lookup = new EventId(5001, "Dmp_Lookup");
public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist");
public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete");
public static final EventId Dmp_Clone = new EventId(5004, "Dmp_Clone");
public static final EventId Dmp_PersistNewVersion = new EventId(5005, "Dmp_PersistNewVersion");
public static final EventId Dmp_Assign_Users = new EventId(5006, "Dmp_Assign_Users");
public static final EventId Dmp_RemoveUser = new EventId(5007, "Dmp_RemoveUser");
public static final EventId Dmp_Invite_Users = new EventId(5008, "Dmp_Invite_Users");
public static final EventId Dmp_Invite_Accept = new EventId(5009, "Dmp_Invite_Accept");
public static final EventId Dmp_PublicQuery = new EventId(5010, "Dmp_PublicQuery");
public static final EventId Dmp_Export = new EventId(5011, "Dmp_Export");
public static final EventId Dmp_PublicLookup = new EventId(5012, "Dmp_PublicLookup");
public static final EventId Dmp_Finalize = new EventId(5013, "Dmp_Finalize");
public static final EventId Dmp_Undo_Finalize = new EventId(5014, "Dmp_Undo_Finalize");
public static final EventId Dmp_Validate = new EventId(5015, "Dmp_Validate");
public static final EventId Description_Query = new EventId(6000, "Description_Query");
public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup");
public static final EventId Description_Persist = new EventId(6002, "Description_Persist");
public static final EventId Description_Delete = new EventId(6003, "Description_Delete");
public static final EventId Description_PublicQuery = new EventId(6004, "Description_PublicQuery");
public static final EventId Description_PublicLookup = new EventId(6005, "Description_PublicLookup");
public static final EventId Description_PersistStatus = new EventId(6006, "Description_PersistStatus");
public static final EventId Description_UploadFieldFiles = new EventId(6007, "Description_UploadFieldFiles");
public static final EventId Description_GetFieldFile = new EventId(6008, "Description_GetFieldFile");
public static final EventId Description_Validate = new EventId(6009, "Description_Validate");
public static final EventId Description_GetDescriptionSectionPermissions = new EventId(6010, "Description_GetDescriptionSectionPermissions");
public static final EventId Description_UpdateDescriptionTemplate = new EventId(6011, "Description_UpdateDescriptionTemplate");
public static final EventId Reference_Query = new EventId(7000, "Reference_Query");
public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup");
public static final EventId Reference_Persist = new EventId(7002, "Reference_Persist");
public static final EventId Reference_Delete = new EventId(7003, "Reference_Delete");
public static final EventId Reference_Search = new EventId(7004, "Reference_Search");
public static final EventId DescriptionTemplate_Query = new EventId(8000, "DescriptionTemplate_Query");
public static final EventId DescriptionTemplate_Lookup = new EventId(8001, "DescriptionTemplate_Lookup");
public static final EventId DescriptionTemplate_Persist = new EventId(8002, "DescriptionTemplate_Persist");
public static final EventId DescriptionTemplate_Delete = new EventId(8003, "DescriptionTemplate_Delete");
public static final EventId DescriptionTemplate_Clone = new EventId(8004, "DescriptionTemplate_Clone");
public static final EventId DescriptionTemplate_PersistNewVersion = new EventId(8005, "DescriptionTemplate_PersistNewVersion");
public static final EventId DescriptionTemplate_GetXml = new EventId(8006, "DescriptionTemplate_GetXml");
public static final EventId DescriptionTemplate_Import = new EventId(8007, "DescriptionTemplate_Import");
public static final EventId SupportiveMaterial_Query = new EventId(9000, "SupportiveMaterial_Query");
public static final EventId SupportiveMaterial_Lookup = new EventId(9001, "SupportiveMaterial_Lookup");
public static final EventId SupportiveMaterial_Persist = new EventId(9002, "SupportiveMaterial_Persist");
public static final EventId SupportiveMaterial_Delete = new EventId(9003, "SupportiveMaterial_Delete");
public static final EventId ReferenceType_Query = new EventId(10000, "ReferenceType_Query");
public static final EventId ReferenceType_Lookup = new EventId(10001, "ReferenceType_Lookup");
public static final EventId ReferenceType_Persist = new EventId(10002, "ReferenceType_Persist");
public static final EventId ReferenceType_Delete = new EventId(10003, "ReferenceType_Delete");
public static final EventId User_Query = new EventId(11000, "User_Query");
public static final EventId User_Lookup = new EventId(11001, "User_Lookup");
public static final EventId User_Persist = new EventId(11002, "User_Persist");
public static final EventId User_Delete = new EventId(11003, "User_Delete");
public static final EventId User_LookupByEmail = new EventId(11004, "User_LookupByEmail");
public static final EventId User_ExportCsv = new EventId(11005, "User_ExportCsv");
public static final EventId User_PersistRoles = new EventId(11006, "User_PersistRoles");
public static final EventId User_LanguageMine = new EventId(11007, "User_LanguageMine");
public static final EventId User_TimezoneMine = new EventId(11008, "User_TimezoneMine");
public static final EventId User_CultureMine = new EventId(11009, "User_CultureMine");
public static final EventId User_MergeRequest = new EventId(11010, "User_MergeRequest");
public static final EventId User_MergeConfirm = new EventId(11011, "User_MergeConfirm");
public static final EventId User_RemoveCredentialRequest = new EventId(11012, "User_RemoveCredentialRequest");
public static final EventId User_RemoveCredentialConfirm = new EventId(11013, "User_RemoveCredentialConfirm");
public static final EventId User_DmpAssociatedQuery = new EventId(11014, "User_DmpAssociatedQuery");
public static final EventId Tenant_Query = new EventId(12000, "Tenant_Query");
public static final EventId Tenant_Lookup = new EventId(12001, "Tenant_Lookup");
public static final EventId Tenant_Persist = new EventId(12002, "Tenant_Persist");
public static final EventId Tenant_Delete = new EventId(12003, "Tenant_Delete");
public static final EventId Language_Query = new EventId(13000, "Language_Query");
public static final EventId Language_Lookup = new EventId(13001, "Language_Lookup");
public static final EventId Language_Persist = new EventId(13002, "Language_Persist");
public static final EventId Language_Delete = new EventId(13003, "Language_Delete");
public static final EventId StorageFile_Download = new EventId(14000, "StorageFile_Download");
public static final EventId StorageFile_Upload = new EventId(14001, "StorageFile_Upload");
public static final EventId StorageFile_Query = new EventId(14002, "StorageFile_Query");
public static final EventId Dashboard_MyRecentActivityItems = new EventId(15000, "Dashboard_MyRecentActivityItems");
public static final EventId Dashboard_MyDashboardStatistics = new EventId(15001, "Dashboard_MyDashboardStatistics");
public static final EventId Dashboard_PublicDashboardStatistics = new EventId(15002, "Dashboard_PublicDashboardStatistics");
public static final EventId Notification_Persist = new EventId(16000, "Notification_Persist");
public static final EventId Lock_Query = new EventId(17000, "Lock_Query");
public static final EventId Lock_Lookup = new EventId(17001, "Lock_Lookup");
public static final EventId Lock_Persist = new EventId(17002, "Lock_Persist");
public static final EventId Lock_Delete = new EventId(17003, "Lock_Delete");
public static final EventId Lock_IsLocked = new EventId(17004, "Lock_IsLocked");
public static final EventId Lock_UnLocked = new EventId(17005, "Lock_UnLocked");
public static final EventId Lock_Touched = new EventId(17006, "Lock_Touched");
public static final EventId Lock_Locked = new EventId(17007, "Lock_Locked");
public static final EventId Deposit_GetAvailableRepositories = new EventId(18000, "Deposit_GetAvailableRepositories");
public static final EventId Deposit_GetAccessToken = new EventId(18001, "Deposit_GetAccessToken");
public static final EventId Deposit_Deposit = new EventId(18002, "Deposit_Deposit");
public static final EventId Deposit_GetLogo = new EventId(18003, "Deposit_GetLogo");
public static final EventId Tag_Query = new EventId(19000, "Tag_Query");
public static final EventId Tag_Lookup = new EventId(19001, "Tag_Lookup");
public static final EventId Tag_Persist = new EventId(19002, "Tag_Persist");
public static final EventId Tag_Delete = new EventId(19003, "Tag_Delete");
public static final EventId FileTransformer_GetAvailableConfigurations = new EventId(20000, "FileTransformer_GetAvailableConfigurations");
public static final EventId ContactSupport_Sent = new EventId(210000, "ContactSupport_Sent");
public static final EventId ContactSupport_PublicSent = new EventId(210001, "ContactSupport_PublicSent");
public static final EventId Maintenance_GenerateElastic = new EventId(220000, "Maintenance_GenerateElastic");
public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic");
public static final EventId Maintenance_SendUserTouchEvents = new EventId(230001, "Maintenance_SendUserTouchEvents");
public static final EventId Maintenance_SendTenantTouchEvents = new EventId(230002, "Maintenance_SendTenantTouchEvents");
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
public static final EventId Principal_MyTenants = new EventId(240001, "Principal_MyTenants");
public static final EventId GetSemantics = new EventId(250000, "GetSemantics");
public static final EventId PrefillingSource_Query = new EventId(260000, "PrefillingSource_Query");
public static final EventId PrefillingSource_Lookup = new EventId(260001, "PrefillingSource_Lookup");
public static final EventId PrefillingSource_Persist = new EventId(260002, "PrefillingSource_Persist");
public static final EventId PrefillingSource_Delete = new EventId(260003, "PrefillingSource_Delete");
public static final EventId PrefillingSource_Generate = new EventId(260004, "PrefillingSource_Generate");
public static final EventId TenantConfiguration_Query = new EventId(270000, "TenantConfiguration_Query");
public static final EventId TenantConfiguration_Lookup = new EventId(270001, "TenantConfiguration_Lookup");
public static final EventId TenantConfiguration_Persist = new EventId(270002, "TenantConfiguration_Persist");
public static final EventId TenantConfiguration_Delete = new EventId(270003, "TenantConfiguration_Delete");
public static final EventId TenantConfiguration_LookupByType = new EventId(270004, "TenantConfiguration_LookupByType");
}

View File

@ -0,0 +1,40 @@
package org.opencdmp.authorization;
import gr.cite.commons.web.authz.policy.AuthorizationRequirement;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class AffiliatedAuthorizationRequirement implements AuthorizationRequirement {
private final Set<String> requiredPermissions;
private final boolean matchAll;
public AffiliatedAuthorizationRequirement(Set<String> requiredPermissions) {
this(false, requiredPermissions);
}
public AffiliatedAuthorizationRequirement(String... requiredPermissions) {
this(false, requiredPermissions);
}
public AffiliatedAuthorizationRequirement(boolean matchAll, Set<String> requiredPermissions) {
this.matchAll = matchAll;
this.requiredPermissions = requiredPermissions;
}
public AffiliatedAuthorizationRequirement(boolean matchAll, String... requiredPermissions) {
this.requiredPermissions = new HashSet<>();
this.matchAll = matchAll;
this.requiredPermissions.addAll(Arrays.stream(requiredPermissions).distinct().toList());
}
public Set<String> getRequiredPermissions() {
return requiredPermissions;
}
public boolean getMatchAll() {
return matchAll;
}
}

View File

@ -0,0 +1,31 @@
package org.opencdmp.authorization;
import org.opencdmp.commons.enums.DmpUserRole;
import gr.cite.commons.web.authz.policy.AuthorizationResource;
import java.util.HashSet;
import java.util.List;
public class AffiliatedResource extends AuthorizationResource {
private HashSet<DmpUserRole> dmpUserRoles;
public AffiliatedResource() {
dmpUserRoles = new HashSet<>();
}
public AffiliatedResource(DmpUserRole dmpUserRole) {
this(List.of(dmpUserRole));
}
public AffiliatedResource(List<DmpUserRole> dmpUserRoles) {
this.dmpUserRoles = new HashSet<>(dmpUserRoles);
}
public HashSet<DmpUserRole> getDmpUserRoles() {
return dmpUserRoles;
}
public void setDmpUserRoles(HashSet<DmpUserRole> dmpUserRoles) {
this.dmpUserRoles = dmpUserRoles;
}
}

View File

@ -0,0 +1,9 @@
package org.opencdmp.authorization;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration("AppAuthorizationConfiguration")
@EnableConfigurationProperties(AuthorizationProperties.class)
public class AuthorizationConfiguration {
}

View File

@ -0,0 +1,8 @@
package org.opencdmp.authorization;
import java.util.EnumSet;
public enum AuthorizationFlags {
None, Permission, DmpAssociated, Public, Owner;
public static final EnumSet<AuthorizationFlags> OwnerOrDmpAssociatedOrPermission = EnumSet.of(DmpAssociated, Permission, Owner);
}

View File

@ -0,0 +1,50 @@
package org.opencdmp.authorization;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.HashSet;
import java.util.List;
@ConfigurationProperties(prefix = "authorization")
public class AuthorizationProperties {
private String globalAdminRole;
public String getGlobalAdminRole() {
return globalAdminRole;
}
public void setGlobalAdminRole(String globalAdminRole) {
this.globalAdminRole = globalAdminRole;
}
private Boolean autoAssignGlobalAdminToNewTenants;
public Boolean getAutoAssignGlobalAdminToNewTenants() {
return autoAssignGlobalAdminToNewTenants;
}
public void setAutoAssignGlobalAdminToNewTenants(Boolean autoAssignGlobalAdminToNewTenants) {
this.autoAssignGlobalAdminToNewTenants = autoAssignGlobalAdminToNewTenants;
}
private List<String> allowedTenantRoles;
public List<String> getAllowedTenantRoles() {
return allowedTenantRoles;
}
public void setAllowedTenantRoles(List<String> allowedTenantRoles) {
this.allowedTenantRoles = allowedTenantRoles;
}
private List<String> allowedGlobalRoles;
public List<String> getAllowedGlobalRoles() {
return allowedGlobalRoles;
}
public void setAllowedGlobalRoles(List<String> allowedGlobalRoles) {
this.allowedGlobalRoles = allowedGlobalRoles;
}
}

View File

@ -0,0 +1,9 @@
package org.opencdmp.authorization;
public class ClaimNames {
public static final String ExternalProviderName = "ExternalProviderName";
public static final String TenantCodesClaimName = "TenantCodes";
public static final String TenantClaimName = "x-tenant";
public static final String GlobalRolesClaimName = "GlobalRoles";
public static final String TenantRolesClaimName = "TenantRoles";
}

View File

@ -0,0 +1,6 @@
package org.opencdmp.authorization;
import gr.cite.commons.web.authz.policy.AuthorizationRequirement;
public class OwnedAuthorizationRequirement implements AuthorizationRequirement {
}

View File

@ -0,0 +1,26 @@
package org.opencdmp.authorization;
import gr.cite.commons.web.authz.policy.AuthorizationResource;
import java.util.List;
import java.util.UUID;
public class OwnedResource extends AuthorizationResource {
private List<UUID> userIds;
public OwnedResource(UUID userId) {
this(List.of(userId));
}
public OwnedResource(List<UUID> userIds) {
this.userIds = userIds;
}
public List<UUID> getUserIds() {
return userIds;
}
public void setUserIds(List<UUID> userIds) {
this.userIds = userIds;
}
}

View File

@ -0,0 +1,222 @@
package org.opencdmp.authorization;
public final class Permission {
/////
public static String DeferredAffiliation = "DeferredAffiliation";
//Public
public static String PublicBrowseDescription = "PublicBrowseDescription";
public static String PublicBrowseDescriptionTemplate = "PublicBrowseDescriptionTemplate";
public static String PublicBrowseDmp = "PublicBrowseDmp";
public static String PublicBrowseDmpReference = "PublicBrowseDmpReference";
public static String PublicBrowseDmpUser = "PublicBrowseDmpUser";
public static String PublicBrowseReference = "PublicBrowseReference";
public static String PublicBrowseUser = "PublicBrowseUser";
public static String PublicBrowseDashboardStatistics = "PublicBrowseDashboardStatistics";
public static String PublicSendContactSupport = "PublicSendContactSupport";
public static String PublicBrowseReferenceType = "PublicBrowseReferenceType";
//Elastic
public static String ManageElastic = "ManageElastic";
//Queue Events
public static String ManageQueueEvents = "ManageQueueEvents";
//Deposit
public static String BrowseDeposit = "BrowseDeposit";
public static String EditDeposit = "BrowseDeposit";
//Language
public static String BrowseLanguage = "BrowseLanguage";
public static String EditLanguage = "EditLanguage";
public static String DeleteLanguage = "DeleteLanguage";
//NotificationTemplate
public static String BrowseNotificationTemplate = "BrowseNotificationTemplate";
public static String EditNotificationTemplate = "EditNotificationTemplate";
public static String DeleteNotificationTemplate = "DeleteNotificationTemplate";
//Language
public static String BrowseStatistics = "BrowseStatistics";
public static String BrowsePublicStatistics = "BrowsePublicStatistics";
//DescriptionTemplate
public static String BrowseDescriptionTemplate = "BrowseDescriptionTemplate";
public static String EditDescriptionTemplate = "EditDescriptionTemplate";
public static String DeleteDescriptionTemplate = "DeleteDescriptionTemplate";
public static String CloneDescriptionTemplate = "CloneDescriptionTemplate";
public static String CreateNewVersionDescriptionTemplate = "CreateNewVersionDescriptionTemplate";
public static String ImportDescriptionTemplate = "ImportDescriptionTemplate";
public static String ExportDescriptionTemplate = "ExportDescriptionTemplate";
//User
public static String BrowseUser = "BrowseUser";
public static String EditUser = "EditUser";
public static String DeleteUser = "DeleteUser";
public static String ExportUsers = "ExportUsers";
public static String BrowseDmpAssociatedUser = "BrowseDmpAssociatedUser";
//StorageFile
public static String BrowseStorageFile = "BrowseStorageFile";
public static String EditStorageFile = "EditStorageFile";
public static String DeleteStorageFile = "DeleteStorageFile";
//DescriptionTemplateType
public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType";
public static String EditDescriptionTemplateType = "EditDescriptionTemplateType";
public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType";
//Dmp
public static String BrowseDmp = "BrowseDmp";
public static String EditDmp = "EditDmp";
public static String NewDmp = "NewDmp";
public static String DepositDmp = "DepositDmp";
public static String DeleteDmp = "DeleteDmp";
public static String CloneDmp = "CloneDmp";
public static String ExportDmp = "ExportDmp";
public static String CreateNewVersionDmp = "CreateNewVersionDmp";
public static String FinalizeDmp = "FinalizeDmp";
public static String UndoFinalizeDmp = "UndoFinalizeDmp";
public static String AssignDmpUsers = "AssignDmpUsers";
public static String InviteDmpUsers = "InviteDmpUsers";
//DmpBlueprint
public static String BrowseDmpBlueprint = "BrowseDmpBlueprint";
public static String EditDmpBlueprint = "EditDmpBlueprint";
public static String DeleteDmpBlueprint = "DeleteDmpBlueprint";
public static String CloneDmpBlueprint = "CloneDmpBlueprint";
public static String CreateNewVersionDmpBlueprint = "CreateNewVersionDmpBlueprint";
public static String ExportDmpBlueprint = "ExportDmpBlueprint";
public static String ImportDmpBlueprint = "ImportDmpBlueprint";
//DmpDescriptionTemplate
public static String BrowseDmpDescriptionTemplate = "BrowseDmpDescriptionTemplate";
public static String EditDmpDescriptionTemplate = "EditDmpDescriptionTemplate";
public static String DeleteDmpDescriptionTemplate = "DeleteDmpDescriptionTemplate";
//DmpUser
public static String BrowseDmpUser = "BrowseDmpUser";
public static String EditDmpUser = "EditDmpUser";
public static String DeleteDmpUser = "DeleteDmpUser";
//Description
public static String BrowseDescription = "BrowseDescription";
public static String EditDescription = "EditDescription";
public static String FinalizeDescription = "FinalizeDescription";
public static String DeleteDescription = "DeleteDescription";
public static String CloneDescription = "CloneDescription";
//DescriptionTag
public static String BrowseDescriptionTag = "BrowseDescriptionTag";
public static String EditDescriptionTag = "EditDescriptionTag";
public static String DeleteDescriptionTag = "DeleteDescriptionTag";
//DescriptionTemplateType
public static String BrowseEntityDoi = "BrowseEntityDoi";
public static String EditEntityDoi = "EditEntityDoi";
public static String DeleteEntityDoi = "DeleteEntityDoi";
//UserSettings
public static String BrowseUserSettings = "BrowseUserSettings";
public static String EditUserSettings = "EditUserSettings";
public static String DeleteUserSettings = "DeleteUserSettings";
//Reference
public static String BrowseReference = "BrowseReference";
public static String EditReference = "EditReference";
public static String DeleteReference = "DeleteReference";
//Tag
public static String BrowseTag = "BrowseTag";
public static String EditTag = "EditTag";
public static String DeleteTag = "DeleteTag";
//DmpReference
public static String BrowseDmpReference = "BrowseDmpReference";
public static String EditDmpReference = "EditDmpReference";
public static String DeleteDmpReference = "DeleteDmpReference";
//DescriptionReference
public static String BrowseDescriptionReference = "BrowseDescriptionReference";
public static String EditDescriptionReference = "EditDescriptionReference";
public static String DeleteDescriptionReference = "DeleteDescriptionReference";
//SupportiveMaterial
public static String BrowseSupportiveMaterial = "BrowseSupportiveMaterial";
public static String EditSupportiveMaterial= "EditSupportiveMaterial";
public static String DeleteSupportiveMaterial = "DeleteSupportiveMaterial";
//ReferenceType
public static String BrowseReferenceType = "BrowseReferenceType";
public static String EditReferenceType= "EditReferenceType";
public static String DeleteReferenceType = "DeleteReferenceType";
//Tenant
public static String BrowseTenant = "BrowseTenant";
public static String EditTenant= "EditTenant";
public static String DeleteTenant = "DeleteTenant";
public static String AllowNoTenant = "AllowNoTenant";
//TenantConfiguration
public static String BrowseTenantConfiguration = "BrowseTenantConfiguration";
public static String EditTenantConfiguration = "EditTenantConfiguration";
public static String DeleteTenantConfiguration = "DeleteTenantConfiguration";
//TenantUser
public static String BrowseTenantUser = "BrowseTenantUser";
public static String EditTenantUser = "EditTenantUser";
public static String DeleteTenantUser = "DeleteTenantUser";
//Prefilling
public static String BrowsePrefilling = "BrowsePrefilling";
//Lock
public static String BrowseLock = "BrowseLock";
public static String EditLock = "EditLock";
public static String DeleteLock = "DeleteLock";
//ContactSupport
public static String SendContactSupport = "SendContactSupport";
//ActionConfirmation
public static String BrowseActionConfirmation = "BrowseActionConfirmation";
public static String EditActionConfirmation = "EditActionConfirmation";
public static String DeleteActionConfirmation = "DeleteActionConfirmation";
//PrefillingSource
public static String BrowsePrefillingSource = "BrowsePrefillingSource";
public static String EditPrefillingSource= "EditPrefillingSource";
public static String DeletePrefillingSource = "DeletePrefillingSource";
// UI Pages
public static String ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage";
public static String ViewMaintenancePage = "ViewMaintenancePage";
public static String ViewNotificationPage = "ViewNotificationPage";
public static String ViewNotificationTemplatePage = "ViewNotificationTemplatePage";
public static String ViewSupportiveMaterialPage = "ViewSupportiveMaterialPage";
public static String ViewLanguagePage = "ViewLanguagePage";
public static String ViewUserPage = "ViewUserPage";
public static String ViewTenantPage = "ViewTenantPage";
public static String ViewPrefillingSourcePage = "ViewPrefillingSourcePage";
public static String ViewReferenceTypePage = "ViewReferenceTypePage";
public static String ViewReferencePage = "ViewReferencePage";
public static String ViewEntityLockPage = "ViewEntityLockPage";
public static String ViewDescriptionTemplatePage = "ViewDescriptionTemplatePage";
public static String ViewDmpBlueprintPage = "ViewDmpBlueprintPage";
public static String ViewPublicDescriptionPage = "ViewPublicDescriptionPage";
public static String ViewPublicDmpPage = "ViewPublicDmpPage";
public static String ViewMyDescriptionPage = "ViewMyDescriptionPage";
public static String ViewMyDmpPage = "ViewMyDmpPage";
public static String ViewHomePage = "ViewHomePage";
public static String ViewMineInAppNotificationPage = "ViewMineInAppNotificationPage";
public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage";
}

View File

@ -0,0 +1,40 @@
package org.opencdmp.authorization;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.service.deposit.DepositServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
public class PermissionNameProvider {
private static final Logger logger = LoggerFactory.getLogger(PermissionNameProvider.class);
private final List<String> permissions;
public PermissionNameProvider(ConventionService conventionService) {
this.permissions = new ArrayList<>();
Class<Permission> clazz = Permission.class;
for (Field f : clazz.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers())) {
try {
Object value = f.get(null);
if (value != null && !conventionService.isNullOrEmpty((String)value)) this.permissions.add((String)value);
} catch (Exception e) {
logger.error("Can not load permission " + f.getName() + " " + e.getMessage());
}
}
}
}
public List<String> getPermissions() {
return permissions;
}
}

View File

@ -0,0 +1,10 @@
package org.opencdmp.authorization.authorizationcontentresolver;
import gr.cite.tools.cache.CacheOptions;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "cache.affiliation")
public class AffiliationCacheOptions extends CacheOptions {
}

View File

@ -0,0 +1,108 @@
package org.opencdmp.authorization.authorizationcontentresolver;
import org.opencdmp.authorization.AffiliatedResource;
import org.opencdmp.convention.ConventionService;
import gr.cite.tools.cache.CacheService;
import gr.cite.tools.exception.MyApplicationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
@Service
public class AffiliationCacheService extends CacheService<AffiliationCacheService.AffiliationCacheValue> {
public static class AffiliationCacheValue {
public AffiliationCacheValue() {
}
public AffiliationCacheValue(UUID tenantId, UUID userId, UUID entityId, String entityType, AffiliatedResource affiliatedResource) {
this.userId = userId;
this.tenantId = tenantId;
this.entityId = entityId;
this.entityType = entityType;
this.affiliatedResource = affiliatedResource;
}
private UUID userId;
private UUID tenantId;
private UUID entityId;
private String entityType;
private AffiliatedResource affiliatedResource;
public UUID getUserId() {
return userId;
}
public void setUserId(UUID userId) {
this.userId = userId;
}
public UUID getTenantId() {
return tenantId;
}
public void setTenantId(UUID tenantId) {
this.tenantId = tenantId;
}
public UUID getEntityId() {
return entityId;
}
public void setEntityId(UUID entityId) {
this.entityId = entityId;
}
public String getEntityType() {
return entityType;
}
public void setEntityType(String entityType) {
this.entityType = entityType;
}
public AffiliatedResource getAffiliatedResource() {
return affiliatedResource;
}
public void setAffiliatedResource(AffiliatedResource affiliatedResource) {
this.affiliatedResource = affiliatedResource;
}
}
private final ConventionService conventionService;
@Autowired
public AffiliationCacheService(AffiliationCacheOptions options, ConventionService conventionService) {
super(options);
this.conventionService = conventionService;
}
@Override
protected Class<AffiliationCacheValue> valueClass() {
return AffiliationCacheValue.class;
}
@Override
public String keyOf(AffiliationCacheValue value) {
return this.buildKey(value.getTenantId(), value.getUserId(), value.getEntityId(), value.getEntityType());
}
public String buildKey(UUID tenantId, UUID userId, UUID entityId, String entityType) {
if (userId == null) throw new IllegalArgumentException("userId id is required");
if (entityId == null) throw new IllegalArgumentException("entityId id is required");
if (this.conventionService.isNullOrEmpty(entityType)) throw new IllegalArgumentException("entityType id is required");
HashMap<String, String> keyParts = new HashMap<>();
keyParts.put("$user$", userId.toString().replace("-", "").toLowerCase(Locale.ROOT));
keyParts.put("$tenant$", tenantId == null ? "" : userId.toString().replace("-", "").toLowerCase(Locale.ROOT));
keyParts.put("$entity$", entityId.toString().replace("-", "").toLowerCase(Locale.ROOT));
keyParts.put("$type$", entityType);
return this.generateKey(keyParts);
}
}

View File

@ -0,0 +1,23 @@
package org.opencdmp.authorization.authorizationcontentresolver;
import org.opencdmp.authorization.AffiliatedResource;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public interface AuthorizationContentResolver {
List<String> getPermissionNames();
AffiliatedResource dmpAffiliation(UUID id);
Map<UUID, AffiliatedResource> dmpsAffiliation(List<UUID> ids);
AffiliatedResource descriptionAffiliation(UUID id);
Map<UUID, AffiliatedResource> descriptionsAffiliation(List<UUID> ids);
AffiliatedResource descriptionsAffiliationBySection(UUID dmpId, UUID sectionId);
Map<UUID, AffiliatedResource> descriptionsAffiliationBySections(UUID dmpId, List<UUID> sectionIds);
}

View File

@ -0,0 +1,174 @@
package org.opencdmp.authorization.authorizationcontentresolver;
import org.opencdmp.authorization.AffiliatedResource;
import org.opencdmp.authorization.PermissionNameProvider;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.data.DescriptionEntity;
import org.opencdmp.data.DmpDescriptionTemplateEntity;
import org.opencdmp.data.DmpEntity;
import org.opencdmp.data.DmpUserEntity;
import org.opencdmp.model.Description;
import org.opencdmp.model.DmpDescriptionTemplate;
import org.opencdmp.model.DmpUser;
import org.opencdmp.query.DescriptionQuery;
import org.opencdmp.query.DmpDescriptionTemplateQuery;
import org.opencdmp.query.DmpUserQuery;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.fieldset.BaseFieldSet;
import org.springframework.stereotype.Service;
import org.springframework.web.context.annotation.RequestScope;
import javax.management.InvalidApplicationException;
import java.util.*;
import java.util.stream.Collectors;
@Service
@RequestScope
public class AuthorizationContentResolverImpl implements AuthorizationContentResolver {
private final QueryFactory queryFactory;
private final UserScope userScope;
private final TenantScope tenantScope;
private final AffiliationCacheService affiliationCacheService;
private final PermissionNameProvider permissionNameProvider;
public AuthorizationContentResolverImpl(QueryFactory queryFactory, UserScope userScope, TenantScope tenantScope, AffiliationCacheService affiliationCacheService, PermissionNameProvider permissionNameProvider) {
this.queryFactory = queryFactory;
this.userScope = userScope;
this.tenantScope = tenantScope;
this.affiliationCacheService = affiliationCacheService;
this.permissionNameProvider = permissionNameProvider;
}
@Override
public List<String> getPermissionNames() {
return permissionNameProvider.getPermissions();
}
@Override
public AffiliatedResource dmpAffiliation(UUID id) {
return this.dmpsAffiliation(List.of(id)).getOrDefault(id, new AffiliatedResource());
}
@Override
public Map<UUID, AffiliatedResource> dmpsAffiliation(List<UUID> ids){
UUID userId = this.userScope.getUserIdSafe();
Map<UUID, AffiliatedResource> affiliatedResources = new HashMap<>();
for (UUID id : ids){
affiliatedResources.put(id, new AffiliatedResource());
}
if (userId == null || !userScope.isSet()) return affiliatedResources;
List<UUID> idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DmpEntity.class.getSimpleName());
if (idsToResolve.isEmpty()) return affiliatedResources;
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(ids).sectionIsEmpty(true).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._dmp));
for (DmpUserEntity dmpUser : dmpUsers){
affiliatedResources.get(dmpUser.getDmpId()).getDmpUserRoles().add(dmpUser.getRole());
}
this.ensureAffiliatedInCache(idsToResolve, userId, affiliatedResources, DmpEntity.class.getSimpleName());
return affiliatedResources;
}
@Override
public AffiliatedResource descriptionAffiliation(UUID id) {
return this.descriptionsAffiliation(List.of(id)).getOrDefault(id, new AffiliatedResource());
}
@Override
public Map<UUID, AffiliatedResource> descriptionsAffiliation(List<UUID> ids){
UUID userId = this.userScope.getUserIdSafe();
Map<UUID, AffiliatedResource> affiliatedResources = new HashMap<>();
for (UUID id : ids){
affiliatedResources.put(id, new AffiliatedResource());
}
if (userId == null || !userScope.isSet()) return affiliatedResources;
List<UUID> idsToResolve = this.getAffiliatedFromCache(ids, userId, affiliatedResources, DescriptionEntity.class.getSimpleName());
if (idsToResolve.isEmpty()) return affiliatedResources;
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._dmpDescriptionTemplate).ensure(Description._dmp));
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntities = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntities.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplate._id).ensure(DmpDescriptionTemplate._sectionId));
Map<UUID, DmpDescriptionTemplateEntity> dmpDescriptionTemplateEntityMap = dmpDescriptionTemplateEntities == null ? new HashMap<>() : dmpDescriptionTemplateEntities.stream().collect(Collectors.toMap(DmpDescriptionTemplateEntity::getId, x-> x));
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).descriptionIds(ids).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._sectionId).ensure(DmpUser._dmp));
Map<UUID, List<DmpUserEntity>> dmpUsersMap = dmpUsers.stream().collect(Collectors.groupingBy(DmpUserEntity::getDmpId));
for (DescriptionEntity description : descriptionEntities){
List<DmpUserEntity> dmpDescriptionUsers = dmpUsersMap.getOrDefault(description.getDmpId(), new ArrayList<>());
for (DmpUserEntity dmpUser : dmpDescriptionUsers) {
if (dmpUser.getSectionId() == null) affiliatedResources.get(description.getId()).getDmpUserRoles().add(dmpUser.getRole());
else {
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = dmpDescriptionTemplateEntityMap.getOrDefault(description.getDmpDescriptionTemplateId(), null);
if (dmpDescriptionTemplateEntity != null && dmpUser.getSectionId().equals(dmpDescriptionTemplateEntity.getSectionId())){
affiliatedResources.get(description.getId()).getDmpUserRoles().add(dmpUser.getRole());
}
}
}
}
this.ensureAffiliatedInCache(idsToResolve, userId, affiliatedResources, DescriptionEntity.class.getSimpleName());
return affiliatedResources;
}
@Override
public AffiliatedResource descriptionsAffiliationBySection(UUID dmpId, UUID sectionId){
return this.descriptionsAffiliationBySections(dmpId, List.of(sectionId)).getOrDefault(sectionId, new AffiliatedResource());
}
@Override
public Map<UUID, AffiliatedResource> descriptionsAffiliationBySections(UUID dmpId, List<UUID> sectionIds){
UUID userId = this.userScope.getUserIdSafe();
Map<UUID, AffiliatedResource> affiliatedResources = new HashMap<>();
for (UUID id : sectionIds){
affiliatedResources.put(id, new AffiliatedResource());
}
if (userId == null || !userScope.isSet()) return affiliatedResources;
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmpId).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(DmpUser._role).ensure(DmpUser._sectionId).ensure(DmpUser._dmp));
for (UUID sectionId : sectionIds.stream().distinct().toList()){
List<DmpUserEntity> dmpSectionUsers = dmpUsers.stream().filter(x-> x.getSectionId() == null || x.getSectionId().equals(sectionId)).toList();
for (DmpUserEntity dmpUser : dmpSectionUsers) {
if (dmpUser.getSectionId() == null) affiliatedResources.get(sectionId).getDmpUserRoles().add(dmpUser.getRole());
else {
if (dmpUser.getSectionId().equals(sectionId)){
affiliatedResources.get(sectionId).getDmpUserRoles().add(dmpUser.getRole());
}
}
}
}
return affiliatedResources;
}
private List<UUID> getAffiliatedFromCache(List<UUID> ids, UUID userId, Map<UUID, AffiliatedResource> affiliatedResources, String entityType) {
List<UUID> idsToResolve = new ArrayList<>();
for (UUID id : ids){
AffiliationCacheService.AffiliationCacheValue cacheValue = null;
try {
cacheValue = this.affiliationCacheService.lookup(this.affiliationCacheService.buildKey(this.tenantScope.isSet() ? this.tenantScope.getTenant(): null, userId, id, entityType));
} catch (InvalidApplicationException e) {
throw new RuntimeException(e);
}
if (cacheValue != null) affiliatedResources.put(id, cacheValue.getAffiliatedResource());
else idsToResolve.add(id);
}
return idsToResolve;
}
private void ensureAffiliatedInCache(List<UUID> idsToResolve, UUID userId, Map<UUID, AffiliatedResource> affiliatedResources, String entityType) {
for (UUID id : idsToResolve){
AffiliatedResource affiliatedResource = affiliatedResources.getOrDefault(id, null);
if (affiliatedResource != null) {
AffiliationCacheService.AffiliationCacheValue cacheValue = null;
try {
cacheValue = new AffiliationCacheService.AffiliationCacheValue(this.tenantScope.isSet() ? this.tenantScope.getTenant(): null, userId, id, entityType, affiliatedResource);
} catch (InvalidApplicationException e) {
throw new RuntimeException(e);
}
this.affiliationCacheService.put(cacheValue);
}
}
}
}

View File

@ -0,0 +1,56 @@
package org.opencdmp.commons;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
public class JsonHandlingService {
private final ObjectMapper objectMapper;
public JsonHandlingService() {
this.objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
}
public String toJson(Object item) throws JsonProcessingException {
if (item == null) return null;
return objectMapper.writeValueAsString(item);
}
public String toJsonSafe(Object item) {
if (item == null) return null;
try {
return objectMapper.writeValueAsString(item);
} catch (Exception ex) {
return null;
}
}
public <T> T fromJson(Class<T> type, String json) throws JsonProcessingException {
if (json == null) return null;
return objectMapper.readValue(json, type);
}
public HashMap<String, String> mapFromJson(String json) throws JsonProcessingException {
ObjectReader reader = objectMapper.readerFor(Map.class);
return reader.readValue(json);
}
public <T> T fromJsonSafe(Class<T> type, String json) {
if (json == null) return null;
try {
return objectMapper.readValue(json, type);
} catch (Exception ex) {
return null;
}
}
}

View File

@ -0,0 +1,103 @@
package org.opencdmp.commons;
import com.fasterxml.jackson.core.JsonProcessingException;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.management.InvalidApplicationException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
public class XmlHandlingService {
public String generateXml(Document doc) throws TransformerException {
TransformerFactory tFact = TransformerFactory.newInstance();
Transformer trans = tFact.newTransformer();
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
DOMSource source = new DOMSource(doc);
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
trans.transform(source, result);
return writer.toString();
}
public String toXml(Object item) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(item.getClass());
Marshaller marshaller = context.createMarshaller();
StringWriter out = new StringWriter();
marshaller.marshal(item, out);
return out.toString();
}
public String toXmlSafe(Object item) {
if (item == null) return null;
try {
return this.toXml(item);
} catch (Exception ex) {
return null;
}
}
public <T> T fromXml(Class<T> type, String xmlString) throws JAXBException, InstantiationException, IllegalAccessException, ParserConfigurationException, IOException, SAXException {
JAXBContext jaxbContext = JAXBContext.newInstance(type);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
return (T) jaxbUnmarshaller.unmarshal(new StringReader(xmlString));
}
public <T> T fromXmlSafe(Class<T> type, String xmlString) {
if (xmlString == null) return null;
try {
return this.fromXml(type, xmlString);
} catch (Exception ex) {
return null;
}
}
// public <T extends XmlSerializable<T>> T xmlSerializableFromXml(Class<T> type, String xmlString) throws JAXBException, InstantiationException, IllegalAccessException, ParserConfigurationException, IOException, SAXException {
// T object = type.newInstance();
// return (T) object.fromXml(this.getDocument(xmlString).getDocumentElement());
// }
//
// public <T extends XmlSerializable<T>> T xmlSerializableFromXmlSafe(Class<T> type, String xmlString) {
// if (xmlString == null) return null;
// try {
// return this.xmlSerializableFromXml(type, xmlString);
// } catch (Exception ex) {
// return null;
// }
// }
public Document getDocument(String xml) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
InputSource inputStream = new InputSource(new StringReader(xml));
return docBuilder.parse(inputStream);
}
public Document getDocument() throws ParserConfigurationException {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
return docBuilder.newDocument();
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum ActionConfirmationStatus implements DatabaseEnum<Short> {
Requested((short) 0),
Accepted((short) 1);
private final Short value;
ActionConfirmationStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ActionConfirmationStatus> map = EnumUtils.getEnumValueMap(ActionConfirmationStatus.class);
public static ActionConfirmationStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum ActionConfirmationType implements DatabaseEnum<Short> {
MergeAccount((short) 0),
RemoveCredential((short) 1),
DmpInvitation((short) 2);
private final Short value;
ActionConfirmationType(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ActionConfirmationType> map = EnumUtils.getEnumValueMap(ActionConfirmationType.class);
public static ActionConfirmationType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum ContactInfoType implements DatabaseEnum<Short> {
Email((short) 0);
private final Short value;
ContactInfoType(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ContactInfoType> map = EnumUtils.getEnumValueMap(ContactInfoType.class);
public static ContactInfoType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,31 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionStatus implements DatabaseEnum<Short> {
Draft((short) 0),
Finalized((short) 1),
Canceled((short) 2);
private final Short value;
DescriptionStatus(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionStatus> map = EnumUtils.getEnumValueMap(DescriptionStatus.class);
public static DescriptionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionTemplateStatus implements DatabaseEnum<Short> {
Draft((short) 0),
Finalized((short) 1);
private final Short value;
DescriptionTemplateStatus(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionTemplateStatus> map = EnumUtils.getEnumValueMap(DescriptionTemplateStatus.class);
public static DescriptionTemplateStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionTemplateTypeStatus implements DatabaseEnum<Short> {
Draft((short) 0),
Finalized((short) 1);
private final Short value;
DescriptionTemplateTypeStatus(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionTemplateTypeStatus> map = EnumUtils.getEnumValueMap(DescriptionTemplateTypeStatus.class);
public static DescriptionTemplateTypeStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionTemplateVersionStatus implements DatabaseEnum<Short> {
Current((short) 0),
Previous((short) 1),
NotFinalized((short) 2);
private final Short value;
DescriptionTemplateVersionStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionTemplateVersionStatus> map = EnumUtils.getEnumValueMap(DescriptionTemplateVersionStatus.class);
public static DescriptionTemplateVersionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionValidationOutput implements DatabaseEnum<Short> {
Valid((short) 1),
Invalid((short) 2);
private final Short value;
DescriptionValidationOutput(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionValidationOutput> map = EnumUtils.getEnumValueMap(DescriptionValidationOutput.class);
public static DescriptionValidationOutput of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpAccessType implements DatabaseEnum<Short> {
Public((short) 0), Restricted((short) 1);
private final Short value;
DmpAccessType(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpAccessType> map = EnumUtils.getEnumValueMap(DmpAccessType.class);
public static DmpAccessType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpBlueprintExtraFieldDataType implements DatabaseEnum<Short> {
Text((short) 0),
RichTex((short) 1),
Date((short) 2),
Number((short) 3),
;
private final Short value;
DmpBlueprintExtraFieldDataType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpBlueprintExtraFieldDataType> map = EnumUtils.getEnumValueMap(DmpBlueprintExtraFieldDataType.class);
public static DmpBlueprintExtraFieldDataType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,35 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
System((short) 0),
Extra((short) 1),
ReferenceType((short) 2);
public static class Names {
public static final String System = "system";
public static final String Extra = "extra";
public static final String ReferenceType = "referenceType";
}
private final Short value;
DmpBlueprintFieldCategory(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpBlueprintFieldCategory> map = EnumUtils.getEnumValueMap(DmpBlueprintFieldCategory.class);
public static DmpBlueprintFieldCategory of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpBlueprintStatus implements DatabaseEnum<Short> {
Draft((short) 0),
Finalized((short) 1);
private final Short value;
DmpBlueprintStatus(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpBlueprintStatus> map = EnumUtils.getEnumValueMap(DmpBlueprintStatus.class);
public static DmpBlueprintStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpBlueprintSystemFieldType implements DatabaseEnum<Short> {
Title((short)0),
Description((short)1),
Language((short)2),
Contact((short)3),
AccessRights((short)4),
User((short)5);
private final Short value;
DmpBlueprintSystemFieldType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpBlueprintSystemFieldType> map = EnumUtils.getEnumValueMap(DmpBlueprintSystemFieldType.class);
public static DmpBlueprintSystemFieldType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpBlueprintVersionStatus implements DatabaseEnum<Short> {
Current((short) 0),
Previous((short) 1),
NotFinalized((short) 2);
private final Short value;
DmpBlueprintVersionStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpBlueprintVersionStatus> map = EnumUtils.getEnumValueMap(DmpBlueprintVersionStatus.class);
public static DmpBlueprintVersionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,31 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpStatus implements DatabaseEnum<Short> {
Draft((short) 0), Finalized((short) 1);
private final Short value;
DmpStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpStatus> map = EnumUtils.getEnumValueMap(DmpStatus.class);
public static DmpStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpUserRole implements DatabaseEnum<Short> {
Owner((short) 0),
User((short) 1),
DescriptionContributor((short) 2),
Reviewer((short) 3);
private final Short value;
DmpUserRole(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpUserRole> map = EnumUtils.getEnumValueMap(DmpUserRole.class);
public static DmpUserRole of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpValidationOutput implements DatabaseEnum<Short> {
Valid((short) 1),
Invalid((short) 2);
private final Short value;
DmpValidationOutput(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpValidationOutput> map = EnumUtils.getEnumValueMap(DmpValidationOutput.class);
public static DmpValidationOutput of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpVersionStatus implements DatabaseEnum<Short> {
Current((short) 0),
Previous((short) 1),
NotFinalized((short) 2);
private final Short value;
DmpVersionStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpVersionStatus> map = EnumUtils.getEnumValueMap(DmpVersionStatus.class);
public static DmpVersionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum EntityType implements DatabaseEnum<Short> {
DMP((short) 0);
private final Short value;
EntityType(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, EntityType> map = EnumUtils.getEnumValueMap(EntityType.class);
public static EntityType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,16 @@
package org.opencdmp.commons.enums;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.HashMap;
import java.util.Map;
public class EnumUtils {
public static <EnumType extends Enum<EnumType> & DatabaseEnum<EnumValue>, EnumValue> Map<EnumValue, EnumType> getEnumValueMap(Class<EnumType> enumType){
HashMap<EnumValue, EnumType> map = new HashMap<>();
for (EnumType v : enumType.getEnumConstants()) {
map.put(v.getValue(), v);
}
return map;
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import java.util.Map;
public enum ExternalFetcherApiHTTPMethodType implements DatabaseEnum<Short> {
@XmlEnumValue(value = "0")
GET((short) 0),
@XmlEnumValue(value = "1")
POST((short) 1);
private final Short value;
ExternalFetcherApiHTTPMethodType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ExternalFetcherApiHTTPMethodType> map = EnumUtils.getEnumValueMap(ExternalFetcherApiHTTPMethodType.class);
public static ExternalFetcherApiHTTPMethodType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,35 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import java.util.Map;
public enum ExternalFetcherSourceType implements DatabaseEnum<Short> {
@XmlEnumValue(value = "0")
API((short) 0),
@XmlEnumValue(value = "1")
STATIC((short) 1);
private final Short value;
public static class Names {
public static final String API = "api";
public static final String STATIC = "static";
}
ExternalFetcherSourceType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ExternalFetcherSourceType> map = EnumUtils.getEnumValueMap(ExternalFetcherSourceType.class);
public static ExternalFetcherSourceType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,82 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum FieldType implements DatabaseEnum<String> {
SELECT(Names.Select),
BOOLEAN_DECISION(Names.BooleanDecision),
RADIO_BOX(Names.RadioBox),
INTERNAL_ENTRIES_DMPS(Names.InternalEntitiesDmps),
INTERNAL_ENTRIES_DESCRIPTIONS(Names.InternalEntitiesDescriptions),
CHECK_BOX(Names.CheckBox),
FREE_TEXT(Names.FreeText),
TEXT_AREA(Names.TextArea),
RICH_TEXT_AREA(Names.RichTextarea),
UPLOAD(Names.Upload),
DATE_PICKER(Names.DatePicker),
TAGS(Names.Tags),
REFERENCE_TYPES(Names.ReferenceTypes),
DATASET_IDENTIFIER(Names.DatasetIdentifier),
VALIDATION(Names.Validation);
private final String value;
public static class Names {
public static final String Select = "select";
public static final String BooleanDecision = "booleanDecision";
public static final String RadioBox = "radiobox";
public static final String InternalEntitiesDmps = "internalEntitiesDmps";
public static final String InternalEntitiesDescriptions = "internalEntitiesDescriptions";
public static final String CheckBox = "checkBox";
public static final String FreeText = "freetext";
public static final String TextArea = "textarea";
public static final String RichTextarea = "richTextarea";
public static final String Upload = "upload";
public static final String DatePicker = "datePicker";
public static final String Tags = "tags";
public static final String DatasetIdentifier = "datasetIdentifier";
public static final String Validation = "validation";
public static final String ReferenceTypes = "referenceTypes";
}
FieldType(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
private static final Map<String, FieldType> map = EnumUtils.getEnumValueMap(FieldType.class);
public static FieldType of(String i) {
return map.get(i);
}
public static boolean isReferenceType(FieldType fieldType){
return fieldType.equals(FieldType.REFERENCE_TYPES);
}
public static boolean isTextType(FieldType fieldType){
return fieldType.equals(FieldType.FREE_TEXT) || fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.TEXT_AREA) ||
fieldType.equals(FieldType.RICH_TEXT_AREA) || fieldType.equals(FieldType.UPLOAD) || fieldType.equals(FieldType.BOOLEAN_DECISION) ||
fieldType.equals(FieldType.RADIO_BOX);
}
public static boolean isTextListType(FieldType fieldType){
return fieldType.equals(FieldType.SELECT) || fieldType.equals(FieldType.TAGS) || fieldType.equals(FieldType.INTERNAL_ENTRIES_DMPS) ||
fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS);
}
public static boolean isDateType(FieldType fieldType){
return fieldType.equals(FieldType.DATE_PICKER);
}
public static boolean isExternalIdentifierType(FieldType fieldType){
return fieldType.equals(FieldType.VALIDATION) || fieldType.equals(FieldType.DATASET_IDENTIFIER) ;
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public enum FieldValidationType implements DatabaseEnum<Short> {
None((short) 0),
Required((short) 1),
Url((short) 2);
private final Short value;
FieldValidationType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, FieldValidationType> map = EnumUtils.getEnumValueMap(FieldValidationType.class);
public static FieldValidationType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum IsActive implements DatabaseEnum<Short> {
Inactive((short) 0),
Active((short) 1);
private final Short value;
IsActive(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, IsActive> map = EnumUtils.getEnumValueMap(IsActive.class);
public static IsActive of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,29 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum LockTargetType implements DatabaseEnum<Short> {
Dmp((short) 0),
Description((short) 1),
DmpBlueprint((short) 2),
DescriptionTemplate((short) 3);
private final Short value;
LockTargetType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, LockTargetType> map = EnumUtils.getEnumValueMap(LockTargetType.class);
public static LockTargetType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,36 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.HashMap;
import java.util.Map;
public enum ProviderType implements DatabaseEnum<Integer> {
Google (1),
Facebook ( 2),
Twitter ( 3),
LinkedIn (4),
NativeLogin ( 5),
B2Access ( 6),
ORCID (7),
OpenAire ( 8),
Configurable ( 9),
Zenodo (10),
Keycloack ( 128);
private final Integer value;
ProviderType(Integer value) {
this.value = value;
}
@JsonValue
public Integer getValue() { return this.value; }
private static final Map<Integer, ProviderType> map = EnumUtils.getEnumValueMap(ProviderType.class);
public static ProviderType of(Integer i) {
return map.get(i);
}
}

View File

@ -0,0 +1,31 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum RecentActivityItemType implements DatabaseEnum<Short> {
Dmp((short) 0),
Description((short) 1);
private final Short value;
RecentActivityItemType(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, RecentActivityItemType> map = EnumUtils.getEnumValueMap(RecentActivityItemType.class);
public static RecentActivityItemType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,31 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum RecentActivityOrder implements DatabaseEnum<Short> {
UpdatedAt((short) 0),
Label((short) 1),
Status((short) 2);
private final Short value;
RecentActivityOrder(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, RecentActivityOrder> map = EnumUtils.getEnumValueMap(RecentActivityOrder.class);
public static RecentActivityOrder of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,27 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum ReferenceFieldDataType implements DatabaseEnum<Short> {
Text((short) 0),
Date((short) 1);
private final Short value;
ReferenceFieldDataType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ReferenceFieldDataType> map = EnumUtils.getEnumValueMap(ReferenceFieldDataType.class);
public static ReferenceFieldDataType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,28 @@
package org.opencdmp.commons.enums;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum ReferenceSourceType implements DatabaseEnum<Short> {
Internal((short) 0),
External((short) 1);
private final Short value;
ReferenceSourceType(Short value) {
this.value = value;
}
@Override
public Short getValue() {
return value;
}
private static final Map<Short, ReferenceSourceType> map = EnumUtils.getEnumValueMap(ReferenceSourceType.class);
public static ReferenceSourceType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum StorageFilePermission implements DatabaseEnum<Short> {
Read((short) 0),
Write((short) 1);
private final Short value;
StorageFilePermission(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, StorageFilePermission> map = EnumUtils.getEnumValueMap(StorageFilePermission.class);
public static StorageFilePermission of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum StorageType implements DatabaseEnum<Short> {
Temp((short) 0),
Main((short) 1),
Transformer((short)2),
Deposit((short)3);
private final Short value;
StorageType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, StorageType> map = EnumUtils.getEnumValueMap(StorageType.class);
public static StorageType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,31 @@
package org.opencdmp.commons.enums;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum SupportiveMaterialFieldType implements DatabaseEnum<Short> {
Faq((short) 0),
About((short) 1),
Glossary((short) 2),
TermsOfService((short) 3),
UserGuide((short) 4);
private final Short value;
SupportiveMaterialFieldType(Short value) {
this.value = value;
}
@Override
public Short getValue() {
return value;
}
private static final Map<Short, SupportiveMaterialFieldType> map = EnumUtils.getEnumValueMap(SupportiveMaterialFieldType.class);
public static SupportiveMaterialFieldType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum TenantConfigurationType implements DatabaseEnum<Short> {
DepositPlugins((short) 0),
FileTransformerPlugins((short) 1),
DefaultUserLocale((short) 2),
Logo((short) 3),
CssColors((short) 4);
private final Short value;
TenantConfigurationType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, TenantConfigurationType> map = EnumUtils.getEnumValueMap(TenantConfigurationType.class);
public static TenantConfigurationType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum UserDescriptionTemplateRole implements DatabaseEnum<Short> {
Owner((short) 0),
Member((short) 1);
private final Short value;
UserDescriptionTemplateRole(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, UserDescriptionTemplateRole> map = EnumUtils.getEnumValueMap(UserDescriptionTemplateRole.class);
public static UserDescriptionTemplateRole of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum UserSettingsType implements DatabaseEnum<Short> {
Settings((short) 0),
Config((short) 1);
private final Short value;
UserSettingsType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, UserSettingsType> map = EnumUtils.getEnumValueMap(UserSettingsType.class);
public static UserSettingsType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.enums.notification;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.commons.enums.EnumUtils;
import org.opencdmp.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum NotificationContactType implements DatabaseEnum<Short> {
EMAIL((short) 0),
SLACK_BROADCAST((short) 1),
SMS((short) 2),
IN_APP((short) 3);
private final Short value;
NotificationContactType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, NotificationContactType> map = EnumUtils.getEnumValueMap(NotificationContactType.class);
public static NotificationContactType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,126 @@
package org.opencdmp.commons.fake;
import org.jetbrains.annotations.NotNull;
import org.springframework.util.Assert;
import org.springframework.web.context.request.RequestAttributes;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class FakeRequestAttributes implements RequestAttributes {
private final Map<String, Object> requestAttributeMap = new HashMap<>();
private final Map<String, Runnable> requestDestructionCallbacks = new LinkedHashMap<>(8);
private volatile boolean requestActive = true;
@Override
public Object getAttribute(@NotNull String name, int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (!isRequestActive()) {
throw new IllegalStateException("Cannot ask for request attribute - request is not active anymore!");
}
return this.requestAttributeMap.get(name);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
@Override
public void setAttribute(@NotNull String name, @NotNull Object value, int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (!isRequestActive()) {
throw new IllegalStateException("Cannot set request attribute - request is not active anymore!");
}
this.requestAttributeMap.put(name, value);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
@Override
public void removeAttribute(@NotNull String name, int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (isRequestActive()) {
removeRequestDestructionCallback(name);
this.requestAttributeMap.remove(name);
}
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
@Override
public String @NotNull [] getAttributeNames(int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (!isRequestActive()) {
throw new IllegalStateException("Cannot ask for request attributes - request is not active anymore!");
}
return this.requestAttributeMap.keySet().toArray(new String[0]);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
//return new String[0];
}
@Override
public void registerDestructionCallback(@NotNull String name, @NotNull Runnable callback, int scope) {
if (scope == SCOPE_REQUEST) {
registerRequestDestructionCallback(name, callback);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
protected final void registerRequestDestructionCallback(String name, Runnable callback) {
Assert.notNull(name, "Name must not be null");
Assert.notNull(callback, "Callback must not be null");
synchronized (this.requestDestructionCallbacks) {
this.requestDestructionCallbacks.put(name, callback);
}
}
@Override
public Object resolveReference(@NotNull String key) {
// Not supported
return null;
}
@Override
public @NotNull String getSessionId() {
return "";
}
@Override
public @NotNull Object getSessionMutex() {
return new Object();
}
public void requestCompleted() {
executeRequestDestructionCallbacks();
for (String name : getAttributeNames(RequestAttributes.SCOPE_REQUEST)) {
this.removeAttribute(name, RequestAttributes.SCOPE_REQUEST);
}
this.requestActive = false;
}
private boolean isRequestActive() {
return this.requestActive;
}
private void removeRequestDestructionCallback(String name) {
Assert.notNull(name, "Name must not be null");
synchronized (this.requestDestructionCallbacks) {
this.requestDestructionCallbacks.remove(name);
}
}
private void executeRequestDestructionCallbacks() {
synchronized (this.requestDestructionCallbacks) {
for (Runnable runnable : this.requestDestructionCallbacks.values()) {
runnable.run();
}
this.requestDestructionCallbacks.clear();
}
}
}

View File

@ -0,0 +1,44 @@
package org.opencdmp.commons.fake;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import java.io.Closeable;
public class FakeRequestScope implements Closeable {
private RequestAttributes initialRequestAttributes = null;
private FakeRequestAttributes currentRequestAttributes = null;
boolean isInUse = false;
public FakeRequestScope() {
this.reset();
}
public final void reset() {
this.close();
this.isInUse = true;
this.initialRequestAttributes = RequestContextHolder.getRequestAttributes();
this.currentRequestAttributes = new FakeRequestAttributes();
RequestContextHolder.setRequestAttributes(this.currentRequestAttributes);
}
@Override
public void close() {
if (!this.isInUse)
return;
this.isInUse = false;
if (initialRequestAttributes != null)
RequestContextHolder.setRequestAttributes(initialRequestAttributes);
else
RequestContextHolder.resetRequestAttributes();
if (currentRequestAttributes != null)
currentRequestAttributes.requestCompleted();
this.initialRequestAttributes = null;
this.currentRequestAttributes = null;
}
}

View File

@ -0,0 +1,20 @@
package org.opencdmp.commons.locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(LocaleProperties.class)
public class LocaleConfiguration {
private final LocaleProperties properties;
@Autowired
public LocaleConfiguration(LocaleProperties properties) {
this.properties = properties;
}
public LocaleProperties getProperties() {
return properties;
}
}

View File

@ -0,0 +1,34 @@
package org.opencdmp.commons.locale;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "locale")
public class LocaleProperties {
private String timezone;
private String language;
private String culture;
public String getTimezone() {
return timezone;
}
public void setTimezone(String timezone) {
this.timezone = timezone;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getCulture() {
return culture;
}
public void setCulture(String culture) {
this.culture = culture;
}
}

View File

@ -0,0 +1,58 @@
package org.opencdmp.commons.lock;
import org.springframework.stereotype.Service;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
@Service
public class LockByKeyManager {
private static class LockWrapper {
private final ReentrantLock lock = new ReentrantLock();
private final AtomicInteger numberOfThreadsInQueue = new AtomicInteger(1);
private LockWrapper addThreadInQueue() {
numberOfThreadsInQueue.incrementAndGet();
return this;
}
private int removeThreadFromQueue() {
return numberOfThreadsInQueue.decrementAndGet();
}
}
private static ConcurrentHashMap<String, LockWrapper> locks = new ConcurrentHashMap<String, LockWrapper>();
public void lock(String key) {
LockWrapper lockWrapper = locks.compute(key, (k, v) -> v == null ? new LockWrapper() : v.addThreadInQueue());
lockWrapper.lock.lock();
}
public boolean tryLock(String key, long timeout, TimeUnit unit) throws InterruptedException {
LockWrapper lockWrapper = null;
try {
lockWrapper = locks.compute(key, (k, v) -> v == null ? new LockWrapper() : v.addThreadInQueue());
return lockWrapper.lock.tryLock(timeout, unit);
} catch (Exception ex){
if (lockWrapper != null && lockWrapper.removeThreadFromQueue() == 0) {
// NB : We pass in the specific value to remove to handle the case where another thread would queue right before the removal
locks.remove(key, lockWrapper);
}
throw ex;
}
}
public void unlock(String key) {
LockWrapper lockWrapper = locks.get(key);
lockWrapper.lock.unlock();
if (lockWrapper.removeThreadFromQueue() == 0) {
// NB : We pass in the specific value to remove to handle the case where another thread would queue right before the removal
locks.remove(key, lockWrapper);
}
}
}

View File

@ -0,0 +1,21 @@
package org.opencdmp.commons.metrics;
public class MetricLabels {
public static final String DRAFT = "draft";
public static final String FINALIZED = "finalized";
public static final String PUBLISHED = "published";
public static final String DOIED = "doied";
public static final String ACTIVE = "active";
public static final String USED = "used";
public static final String LOGGEDIN = "loggedin";
public static final String TOTAL = "total";
}

View File

@ -0,0 +1,28 @@
package org.opencdmp.commons.metrics;
public class MetricNames {
public static final String DATASET_TEMPLATE = "argos_dmp_templates";
public static final String INSTALLATIONS = "installations";
public static final String USERS = "argos_users";
public static final String DMP = "argos_managed_dmps";
public static final String DATASET = "argos_managed_dataset_descriptions";
public static final String RESEARCHERS = "argos_researchers";
public static final String PROJECTS = "argos_projects";
public static final String FUNDERS = "argos_funders";
public static final String GRANTS = "argos_grants";
public static final String LANGUAGES = "argos_languages";
public static final String DMP_WITH_GRANT = "argos_managed_dmps_with_grantid";
public static final String NEXUS_PREFIX = "nexus_";
}

View File

@ -0,0 +1,20 @@
package org.opencdmp.commons.notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(NotificationProperties.class)
public class NotificationConfiguration {
private final NotificationProperties properties;
@Autowired
public NotificationConfiguration(NotificationProperties properties) {
this.properties = properties;
}
public NotificationProperties getProperties() {
return properties;
}
}

View File

@ -0,0 +1,136 @@
package org.opencdmp.commons.notification;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.UUID;
@ConfigurationProperties(prefix = "notification")
public class NotificationProperties {
private UUID dmpInvitationExternalUserType;
private UUID dmpInvitationExistingUserType;
private UUID dmpModifiedType;
private UUID dmpFinalisedType;
private UUID descriptionModifiedType;
private UUID descriptionFinalisedType;
private UUID mergeAccountConfirmationType;
private UUID removeCredentialConfirmationType;
private UUID dmpDepositType;
private UUID descriptionTemplateInvitationType;
private UUID contactSupportType;
private UUID publicContactSupportType;
private int emailExpirationTimeSeconds;
private String contactSupportEmail;
public UUID getDmpInvitationExternalUserType() {
return dmpInvitationExternalUserType;
}
public void setDmpInvitationExternalUserType(UUID dmpInvitationExternalUserType) {
this.dmpInvitationExternalUserType = dmpInvitationExternalUserType;
}
public UUID getDmpInvitationExistingUserType() {
return dmpInvitationExistingUserType;
}
public void setDmpInvitationExistingUserType(UUID dmpInvitationExistingUserType) {
this.dmpInvitationExistingUserType = dmpInvitationExistingUserType;
}
public UUID getDmpModifiedType() {
return dmpModifiedType;
}
public void setDmpModifiedType(UUID dmpModifiedType) {
this.dmpModifiedType = dmpModifiedType;
}
public UUID getDmpFinalisedType() {
return dmpFinalisedType;
}
public void setDmpFinalisedType(UUID dmpFinalisedType) {
this.dmpFinalisedType = dmpFinalisedType;
}
public UUID getDescriptionModifiedType() {
return descriptionModifiedType;
}
public void setDescriptionModifiedType(UUID descriptionModifiedType) {
this.descriptionModifiedType = descriptionModifiedType;
}
public UUID getDescriptionFinalisedType() {
return descriptionFinalisedType;
}
public void setDescriptionFinalisedType(UUID descriptionFinalisedType) {
this.descriptionFinalisedType = descriptionFinalisedType;
}
public UUID getMergeAccountConfirmationType() {
return mergeAccountConfirmationType;
}
public void setMergeAccountConfirmationType(UUID mergeAccountConfirmationType) {
this.mergeAccountConfirmationType = mergeAccountConfirmationType;
}
public UUID getRemoveCredentialConfirmationType() {
return removeCredentialConfirmationType;
}
public void setRemoveCredentialConfirmationType(UUID removeCredentialConfirmationType) {
this.removeCredentialConfirmationType = removeCredentialConfirmationType;
}
public UUID getDmpDepositType() {
return dmpDepositType;
}
public void setDmpDepositType(UUID dmpDepositType) {
this.dmpDepositType = dmpDepositType;
}
public UUID getDescriptionTemplateInvitationType() {
return descriptionTemplateInvitationType;
}
public void setDescriptionTemplateInvitationType(UUID descriptionTemplateInvitationType) {
this.descriptionTemplateInvitationType = descriptionTemplateInvitationType;
}
public int getEmailExpirationTimeSeconds() {
return emailExpirationTimeSeconds;
}
public void setEmailExpirationTimeSeconds(int emailExpirationTimeSeconds) {
this.emailExpirationTimeSeconds = emailExpirationTimeSeconds;
}
public UUID getContactSupportType() {
return contactSupportType;
}
public void setContactSupportType(UUID contactSupportType) {
this.contactSupportType = contactSupportType;
}
public UUID getPublicContactSupportType() {
return publicContactSupportType;
}
public void setPublicContactSupportType(UUID publicContactSupportType) {
this.publicContactSupportType = publicContactSupportType;
}
public String getContactSupportEmail() {
return contactSupportEmail;
}
public void setContactSupportEmail(String contactSupportEmail) {
this.contactSupportEmail = contactSupportEmail;
}
}

View File

@ -0,0 +1,9 @@
package org.opencdmp.commons.scope.tenant;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(MultitenancyProperties.class)
public class MultitenancyConfiguration {
}

View File

@ -0,0 +1,25 @@
package org.opencdmp.commons.scope.tenant;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "tenant.multitenancy")
public class MultitenancyProperties {
private boolean isMultitenant;
private String defaultTenantCode;
public boolean isMultitenant() {
return isMultitenant;
}
public void setIsMultitenant(boolean multitenant) {
isMultitenant = multitenant;
}
public String getDefaultTenantCode() {
return defaultTenantCode;
}
public void setDefaultTenantCode(String defaultTenantCode) {
this.defaultTenantCode = defaultTenantCode;
}
}

View File

@ -0,0 +1,126 @@
package org.opencdmp.commons.scope.tenant;
import org.opencdmp.data.tenant.TenantScopedBaseEntity;
import jakarta.persistence.EntityManager;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import javax.management.InvalidApplicationException;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
@Component
@RequestScope
public class TenantScope {
public static final String TenantReplaceParameter = "::TenantCode::";
private final MultitenancyProperties multitenancy;
private final AtomicReference<UUID> tenant = new AtomicReference<>();
private final AtomicReference<String> tenantCode = new AtomicReference<>();
private final AtomicReference<UUID> initialTenant = new AtomicReference<>();
private final AtomicReference<String> initialTenantCode = new AtomicReference<>();
@Autowired
public TenantScope(MultitenancyProperties multitenancy) {
this.multitenancy = multitenancy;
}
public Boolean isMultitenant() {
return multitenancy.isMultitenant();
}
public String getDefaultTenantCode() {
return multitenancy.getDefaultTenantCode();
}
public Boolean isSet() {
if (!this.isMultitenant())
return Boolean.TRUE;
return this.tenant.get() != null || this.isDefaultTenant();
}
public Boolean isDefaultTenant() {
if (!this.isMultitenant())
return Boolean.TRUE;
return this.multitenancy.getDefaultTenantCode().equalsIgnoreCase(this.tenantCode.get());
}
public UUID getTenant() throws InvalidApplicationException {
if (!this.isMultitenant())
return null;
if (this.tenant.get() == null && !this.isDefaultTenant())
throw new InvalidApplicationException("tenant not set");
return this.isDefaultTenant() ? null : this.tenant.get();
}
public String getTenantCode() throws InvalidApplicationException {
if (!this.isMultitenant())
return null;
if (this.tenantCode.get() == null)
throw new InvalidApplicationException("tenant not set");
return this.tenantCode.get();
}
public void setTempTenant(EntityManager entityManager, UUID tenant, String tenantCode) {
this.tenant.set(tenant);
this.tenantCode.set(tenantCode);
entityManager
.unwrap(Session.class)
.disableFilter(TenantScopedBaseEntity.TENANT_FILTER);
entityManager
.unwrap(Session.class)
.disableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER);
if (this.tenant.get() != null || this.isDefaultTenant()) {
if(!this.isDefaultTenant()) {
entityManager
.unwrap(Session.class)
.enableFilter(TenantScopedBaseEntity.TENANT_FILTER)
.setParameter(TenantScopedBaseEntity.TENANT_FILTER_TENANT_PARAM, this.tenant.get().toString());
} else {
entityManager
.unwrap(Session.class)
.enableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER);
}
}
}
public void removeTempTenant(EntityManager entityManager) {
this.tenant.set(this.initialTenant.get());
this.tenantCode.set(this.initialTenantCode.get());
entityManager
.unwrap(Session.class)
.disableFilter(TenantScopedBaseEntity.TENANT_FILTER);
entityManager
.unwrap(Session.class)
.disableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER);
if (this.initialTenant.get() != null || this.isDefaultTenant()) {
if(!this.isDefaultTenant()) {
entityManager
.unwrap(Session.class)
.enableFilter(TenantScopedBaseEntity.TENANT_FILTER)
.setParameter(TenantScopedBaseEntity.TENANT_FILTER_TENANT_PARAM, this.tenant.get().toString());
} else {
entityManager
.unwrap(Session.class)
.enableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER);
}
}
}
public void setTenant(UUID tenant, String tenantCode) {
if (this.isMultitenant()) {
this.tenant.set(tenant);
this.initialTenant.set(tenant);
this.tenantCode.set(tenantCode);
this.initialTenantCode.set(tenantCode);
}
}
}

View File

@ -0,0 +1,9 @@
package org.opencdmp.commons.scope.tenant;
import java.beans.Transient;
import java.util.UUID;
public interface TenantScoped {
void setTenantId(UUID tenantId);
UUID getTenantId();
}

View File

@ -0,0 +1,35 @@
package org.opencdmp.commons.scope.user;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import javax.management.InvalidApplicationException;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
@Component
@RequestScope
public class UserScope {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserScope.class));
private final AtomicReference<UUID> userId = new AtomicReference<>();
public Boolean isSet() {
return this.userId.get() != null;
}
public UUID getUserId() throws InvalidApplicationException {
if (this.userId.get() == null) throw new InvalidApplicationException("user not set");
return this.userId.get();
}
public UUID getUserIdSafe() {
return this.userId.get();
}
public void setUserId(UUID userId) {
this.userId.set(userId);
}
}

View File

@ -0,0 +1,44 @@
package org.opencdmp.commons.types.actionconfirmation;
import org.opencdmp.commons.enums.DmpUserRole;
import jakarta.xml.bind.annotation.*;
import java.util.UUID;
@XmlRootElement(name = "dmp-invitation")
@XmlAccessorType(XmlAccessType.FIELD)
public class DmpInvitationEntity {
@XmlAttribute(name = "email")
private String email;
@XmlAttribute(name = "dmp")
private UUID dmpId;
@XmlAttribute(name = "dmp-role")
private DmpUserRole role;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public UUID getDmpId() {
return dmpId;
}
public void setDmpId(UUID dmpId) {
this.dmpId = dmpId;
}
public DmpUserRole getRole() {
return role;
}
public void setRole(DmpUserRole role) {
this.role = role;
}
}

View File

@ -0,0 +1,22 @@
package org.opencdmp.commons.types.actionconfirmation;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "merge-account-confirmation")
@XmlAccessorType(XmlAccessType.FIELD)
public class MergeAccountConfirmationEntity {
@XmlAttribute(name = "email")
private String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@ -0,0 +1,24 @@
package org.opencdmp.commons.types.actionconfirmation;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.UUID;
@XmlRootElement(name = "remove-credential-confirmation")
@XmlAccessorType(XmlAccessType.FIELD)
public class RemoveCredentialRequestEntity {
@XmlAttribute(name = "credential-id")
private UUID credentialId;
public UUID getCredentialId() {
return credentialId;
}
public void setCredentialId(UUID credentialId) {
this.credentialId = credentialId;
}
}

View File

@ -0,0 +1,62 @@
package org.opencdmp.commons.types.dashborad;
import org.opencdmp.commons.enums.RecentActivityItemType;
import java.time.Instant;
import java.util.UUID;
public class RecentActivityItemEntity {
private RecentActivityItemType type;
private UUID id;
private Instant updatedAt;
private String label;
private Short statusValue;
public RecentActivityItemEntity(RecentActivityItemType type, UUID id, Instant updatedAt, String label, Short statusValue) {
this.type = type;
this.id = id;
this.updatedAt = updatedAt;
this.label = label;
this.statusValue = statusValue;
}
public RecentActivityItemType getType() {
return type;
}
public void setType(RecentActivityItemType type) {
this.type = type;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Short getStatusValue() {
return statusValue;
}
public void setStatusValue(Short statusValue) {
this.statusValue = statusValue;
}
}

View File

@ -0,0 +1,77 @@
package org.opencdmp.commons.types.deposit;
public class DepositSourceEntity {
private String repositoryId;
private String url;
private String issuerUrl;
private String clientId;
private String clientSecret;
private String scope;
private String pdfTransformerId;
private String rdaTransformerId;
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getIssuerUrl() {
return issuerUrl;
}
public void setIssuerUrl(String issuerUrl) {
this.issuerUrl = issuerUrl;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getPdfTransformerId() {
return pdfTransformerId;
}
public void setPdfTransformerId(String pdfTransformerId) {
this.pdfTransformerId = pdfTransformerId;
}
public String getRdaTransformerId() {
return rdaTransformerId;
}
public void setRdaTransformerId(String rdaTransformerId) {
this.rdaTransformerId = rdaTransformerId;
}
}

View File

@ -0,0 +1,25 @@
package org.opencdmp.commons.types.description;
public class ExternalIdentifierEntity {
private String identifier;
private String type;
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,44 @@
package org.opencdmp.commons.types.description;
import java.time.Instant;
import java.util.List;
public class FieldEntity {
private String textValue;
private List<String> textListValue;
private Instant dateValue;
private ExternalIdentifierEntity externalIdentifier;
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public List<String> getTextListValue() {
return textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return dateValue;
}
public void setDateValue(Instant dateValue) {
this.dateValue = dateValue;
}
public ExternalIdentifierEntity getExternalIdentifier() {
return externalIdentifier;
}
public void setExternalIdentifier(ExternalIdentifierEntity externalIdentifier) {
this.externalIdentifier = externalIdentifier;
}
}

View File

@ -0,0 +1,18 @@
package org.opencdmp.commons.types.description;
import java.util.Map;
public class PropertyDefinitionEntity {
private Map<String, PropertyDefinitionFieldSetEntity> fieldSets;
public Map<String, PropertyDefinitionFieldSetEntity> getFieldSets() {
return fieldSets;
}
public void setFieldSets(Map<String, PropertyDefinitionFieldSetEntity> fieldSets) {
this.fieldSets = fieldSets;
}
}

View File

@ -0,0 +1,15 @@
package org.opencdmp.commons.types.description;
import java.util.List;
public class PropertyDefinitionFieldSetEntity {
private List<PropertyDefinitionFieldSetItemEntity> items;
public List<PropertyDefinitionFieldSetItemEntity> getItems() {
return items;
}
public void setItems(List<PropertyDefinitionFieldSetItemEntity> items) {
this.items = items;
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.types.description;
import java.util.Map;
public class PropertyDefinitionFieldSetItemEntity {
private Map<String, FieldEntity> fields;
private String comment;
private int ordinal;
public Map<String, FieldEntity> getFields() {
return fields;
}
public void setFields(Map<String, FieldEntity> fields) {
this.fields = fields;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
}

View File

@ -0,0 +1,15 @@
package org.opencdmp.commons.types.descriptionreference;
import java.util.UUID;
public class DescriptionReferenceDataEntity {
private String fieldId;
public String getFieldId() {
return fieldId;
}
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
}

View File

@ -0,0 +1,50 @@
package org.opencdmp.commons.types.descriptiontemplate;
import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD)
public class DefinitionEntity {
@XmlElementWrapper(name = "pages")
@XmlElement(name = "page")
private List<PageEntity> pages;
public List<PageEntity> getPages() {
return pages;
}
public void setPages(List<PageEntity> pageEntities) {
this.pages = pageEntities;
}
public List<FieldEntity> getAllField(){
List<FieldEntity> fieldEntities = new ArrayList<>();
if (this.getPages() != null){
for (PageEntity sectionEntity: this.getPages()) {
fieldEntities.addAll(sectionEntity.getAllField());
}
}
return fieldEntities;
}
public List<FieldSetEntity> getAllFieldSets(){
List<FieldSetEntity> fieldSetsEntities = new ArrayList<>();
if (this.getPages() != null){
for (PageEntity sectionEntity: this.getPages()) {
fieldSetsEntities.addAll(sectionEntity.getAllFieldSets());
}
}
return fieldSetsEntities;
}
public List<FieldSetEntity> getFieldSetById(String id) {
return this.getAllFieldSets().stream().filter(x-> id.equals(x.getId())).toList();
}
public List<FieldEntity> getFieldById(String id) {
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.types.descriptiontemplate;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class ExternalIdentifierEntity {
@XmlAttribute(name="identifier")
private String identifier;
@XmlAttribute(name="type")
private String type;
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,106 @@
package org.opencdmp.commons.types.descriptiontemplate;
import org.opencdmp.commons.enums.FieldValidationType;
import org.opencdmp.commons.types.descriptiontemplate.fielddata.*;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class FieldEntity {
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")
private int ordinal;
@XmlElementWrapper(name = "schematics")
@XmlElement(name = "schematic")
private List<String> schematics;
@XmlAttribute(name="numbering")
private String numbering;
@XmlAttribute(name="defaultValue")
private String defaultValue;
@XmlElementWrapper(name = "visibilityRules")
@XmlElement(name = "rule")
private List<RuleEntity> visibilityRules;
@XmlElements({
@XmlElement(name = LabelDataEntity.XmlElementName, type = LabelDataEntity.class),
@XmlElement(name = LabelAndMultiplicityDataEntity.XmlElementName, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = UploadDataEntity.XmlElementName, type = UploadDataEntity.class),
@XmlElement(name = RadioBoxDataEntity.XmlElementName, type = RadioBoxDataEntity.class),
@XmlElement(name = SelectDataEntity.XmlElementName, type = SelectDataEntity.class),
@XmlElement(name = ReferenceTypeDataEntity.XmlElementName, type = ReferenceTypeDataEntity.class)
})
private BaseFieldDataEntity data;
@XmlElementWrapper(name = "validations")
@XmlElement(name = "validation")
private List<FieldValidationType> validations;
@XmlAttribute(name="includeInExport")
private Boolean includeInExport;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public List<String> getSchematics() {
return schematics;
}
public void setSchematics(List<String> schematics) {
this.schematics = schematics;
}
public BaseFieldDataEntity getData() {
return data;
}
public void setData(BaseFieldDataEntity data) {
this.data = data;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public List<FieldValidationType> getValidations() {
return validations;
}
public void setValidations(List<FieldValidationType> validations) {
this.validations = validations;
}
public String getNumbering() {
return numbering;
}
public void setNumbering(String numbering) {
this.numbering = numbering;
}
public Boolean getIncludeInExport() {
return includeInExport;
}
public void setIncludeInExport(Boolean includeInExport) {
this.includeInExport = includeInExport;
}
public List<RuleEntity> getVisibilityRules() {
return visibilityRules;
}
public void setVisibilityRules(List<RuleEntity> visibilityRules) {
this.visibilityRules = visibilityRules;
}
}

View File

@ -0,0 +1,121 @@
package org.opencdmp.commons.types.descriptiontemplate;
import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class FieldSetEntity {
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")
private int ordinal;
@XmlElementWrapper(name = "fields")
@XmlElement(name = "field")
private List<FieldEntity> fields;
@XmlAttribute(name="numbering")
private String numbering;
@XmlAttribute(name="title")
private String title;
@XmlAttribute(name="description")
private String description;
@XmlAttribute(name="extendedDescription")
private String extendedDescription;
@XmlAttribute(name="additionalInformation")
private String additionalInformation;
@XmlElement(name="multiplicity")
private MultiplicityEntity multiplicity;
@XmlAttribute(name="hasMultiplicity")
private boolean hasMultiplicity;
@XmlAttribute(name="hasCommentField")
private boolean hasCommentField;
public List<FieldEntity> getFields() {
return fields;
}
public void setFields(List<FieldEntity> fieldEntities) {
this.fields = fieldEntities;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getExtendedDescription() {
return extendedDescription;
}
public void setExtendedDescription(String extendedDescription) {
this.extendedDescription = extendedDescription;
}
public MultiplicityEntity getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(MultiplicityEntity multiplicity) {
this.multiplicity = multiplicity;
}
public boolean getHasCommentField() {
return hasCommentField;
}
public void setHasCommentField(boolean hasCommentField) {
this.hasCommentField = hasCommentField;
}
public String getNumbering() {
return numbering;
}
public void setNumbering(String numbering) {
this.numbering = numbering;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
public List<FieldEntity> getAllField() {
return this.getFields() == null ? new ArrayList<>() : this.getFields();
}
public List<FieldEntity> getFieldById(String id) {
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
}
public boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
}

View File

@ -0,0 +1,50 @@
package org.opencdmp.commons.types.descriptiontemplate;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class MultiplicityEntity {
@XmlAttribute(name="min")
private int min;
@XmlAttribute(name="max")
private int max;
@XmlAttribute(name="placeholder")
private String placeholder;
@XmlAttribute(name="tableView")
private boolean tableView;
public int getMin() {
return min;
}
public void setMin(int min) {
this.min = min;
}
public int getMax() {
return max;
}
public void setMax(int max) {
this.max = max;
}
public String getPlaceholder() {
return placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public boolean getTableView() {
return tableView;
}
public void setTableView(boolean tableView) {
this.tableView = tableView;
}
}

View File

@ -0,0 +1,74 @@
package org.opencdmp.commons.types.descriptiontemplate;
import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class PageEntity {
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")
private int ordinal;
@XmlAttribute(name="title")
private String title;
@XmlElementWrapper(name = "sections")
@XmlElement(name = "section")
private List<SectionEntity> sections;
public List<SectionEntity> getSections() {
return sections;
}
public void setSections(List<SectionEntity> sections) {
this.sections = sections;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<FieldEntity> getAllField(){
List<FieldEntity> fieldEntities = new ArrayList<>();
if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) {
fieldEntities.addAll(sectionEntity.getAllField());
}
}
return fieldEntities;
}
public List<FieldSetEntity> getAllFieldSets(){
List<FieldSetEntity> fieldSetsEntities = new ArrayList<>();
if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) {
fieldSetsEntities.addAll(sectionEntity.getAllFieldSets());
}
}
return fieldSetsEntities;
}
}

View File

@ -0,0 +1,64 @@
package org.opencdmp.commons.types.descriptiontemplate;
import jakarta.xml.bind.annotation.*;
import java.time.Instant;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class RuleEntity {
@XmlAttribute(name="target")
private String target;
@XmlAttribute(name="value")
private String textValue;
@XmlElementWrapper(name = "textListValues")
@XmlElement(name = "textListValue")
private List<String> textListValue;
@XmlElement(name = "dateValue")
private Instant dateValue;
@XmlElement(name="externalIdentifier")
private ExternalIdentifierEntity externalIdentifier;
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public List<String> getTextListValue() {
return textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return dateValue;
}
public void setDateValue(Instant dateValue) {
this.dateValue = dateValue;
}
public ExternalIdentifierEntity getExternalIdentifier() {
return externalIdentifier;
}
public void setExternalIdentifier(ExternalIdentifierEntity externalIdentifier) {
this.externalIdentifier = externalIdentifier;
}
}

View File

@ -0,0 +1,131 @@
package org.opencdmp.commons.types.descriptiontemplate;
import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class SectionEntity{
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")
private int ordinal;
@XmlAttribute(name="defaultVisibility")
private boolean defaultVisibility;
@XmlAttribute(name="numbering")
private String numbering;
@XmlAttribute(name="title")
private String title;
@XmlAttribute(name="description")
private String description;
@XmlAttribute(name="extendedDescription")
private String extendedDescription;
@XmlElementWrapper(name = "sections")
@XmlElement(name = "section")
private List<SectionEntity> sections;
@XmlElementWrapper(name = "fieldSets")
@XmlElement(name = "fieldSet")
private List<FieldSetEntity> fieldSets;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public boolean isDefaultVisibility() {
return defaultVisibility;
}
public void setDefaultVisibility(boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<SectionEntity> getSections() {
return sections;
}
public void setSections(List<SectionEntity> sections) {
this.sections = sections;
}
public List<FieldSetEntity> getFieldSets() {
return fieldSets;
}
public void setFieldSets(List<FieldSetEntity> fieldSetEntities) {
this.fieldSets = fieldSetEntities;
}
public String getExtendedDescription() {
return extendedDescription;
}
public void setExtendedDescription(String extendedDescription) {
this.extendedDescription = extendedDescription;
}
public String getNumbering() {
return numbering;
}
public void setNumbering(String numbering) {
this.numbering = numbering;
}
public List<FieldEntity> getAllField(){
List<FieldEntity> fieldEntities = new ArrayList<>();
if (this.getFieldSets() != null){
for (FieldSetEntity fieldSetEntity: this.getFieldSets()) {
fieldEntities.addAll(fieldSetEntity.getAllField());
}
}
if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) {
fieldEntities.addAll(sectionEntity.getAllField());
}
}
return fieldEntities;
}
public List<FieldSetEntity> getAllFieldSets(){
List<FieldSetEntity> fieldSetEntities = new ArrayList<>();
if (this.getFieldSets() != null){
fieldSetEntities.addAll(this.getFieldSets());
}
if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) {
fieldSetEntities.addAll(sectionEntity.getAllFieldSets());
}
}
return fieldSetEntities;
}
}

View File

@ -0,0 +1,32 @@
package org.opencdmp.commons.types.descriptiontemplate.fielddata;
import org.opencdmp.commons.enums.FieldType;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class BaseFieldDataEntity {
@XmlAttribute(name = "label")
private String label;
@XmlAttribute(name = "fieldType")
private FieldType fieldType;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public FieldType getFieldType() {
return fieldType;
}
public void setFieldType(FieldType fieldType) {
this.fieldType = fieldType;
}
}

View File

@ -0,0 +1,21 @@
package org.opencdmp.commons.types.descriptiontemplate.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class LabelAndMultiplicityDataEntity extends BaseFieldDataEntity {
public static final String XmlElementName = "labelAndMultiplicityData";
@XmlAttribute(name = "multipleSelect")
private Boolean multipleSelect;
public Boolean getMultipleSelect() {
return multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
this.multipleSelect = multipleSelect;
}
}

View File

@ -0,0 +1,10 @@
package org.opencdmp.commons.types.descriptiontemplate.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class LabelDataEntity extends BaseFieldDataEntity {
public static final String XmlElementName = "labelData";
}

View File

@ -0,0 +1,45 @@
package org.opencdmp.commons.types.descriptiontemplate.fielddata;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class RadioBoxDataEntity extends BaseFieldDataEntity {
public static final String XmlElementName = "radioBoxData";
@XmlAccessorType(XmlAccessType.FIELD)
public static class RadioBoxDataOptionEntity {
@XmlAttribute(name="label")
private String label;
@XmlAttribute(name="value")
private String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@XmlElementWrapper(name = "options")
@XmlElement(name = "option")
private List<RadioBoxDataOptionEntity> options;
public List<RadioBoxDataOptionEntity> getOptions() {
return options;
}
public void setOptions(List<RadioBoxDataOptionEntity> options) {
this.options = options;
}
}

View File

@ -0,0 +1,33 @@
package org.opencdmp.commons.types.descriptiontemplate.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD)
public class ReferenceTypeDataEntity extends BaseFieldDataEntity {
public static final String XmlElementName = "referenceTypeData";
@XmlAttribute(name = "multipleSelect")
private Boolean multipleSelect;
@XmlAttribute(name = "referenceTypeId")
private UUID referenceTypeId;
public Boolean getMultipleSelect() {
return multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
this.multipleSelect = multipleSelect;
}
public UUID getReferenceTypeId() {
return referenceTypeId;
}
public void setReferenceTypeId(UUID referenceTypeId) {
this.referenceTypeId = referenceTypeId;
}
}

View File

@ -0,0 +1,44 @@
package org.opencdmp.commons.types.descriptiontemplate.fielddata;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class SelectDataEntity extends LabelAndMultiplicityDataEntity {
public static final String XmlElementName = "selectData";
@XmlElementWrapper(name = "options")
@XmlElement(name = "options")
private List<OptionEntity> options;
public List<OptionEntity> getOptions() {
return options;
}
public void setOptions(List<OptionEntity> optionEntities) {
this.options = optionEntities;
}
@XmlAccessorType(XmlAccessType.FIELD)
public static class OptionEntity {
@XmlAttribute(name="label")
private String label;
@XmlAttribute(name="value")
private String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}

View File

@ -0,0 +1,59 @@
package org.opencdmp.commons.types.descriptiontemplate.fielddata;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class UploadDataEntity extends BaseFieldDataEntity {
public static final String XmlElementName = "uploadData";
@XmlAccessorType(XmlAccessType.FIELD)
public static class UploadDataOptionEntity {
@XmlAttribute(name="label")
private String label;
@XmlAttribute(name="value")
private String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@XmlElementWrapper(name = "types")
@XmlElement(name = "type")
private List<UploadDataOptionEntity> types;
@XmlAttribute(name="maxFileSizeInMB")
private Integer maxFileSizeInMB;
public List<UploadDataOptionEntity> getTypes() {
return types;
}
public void setTypes(List<UploadDataOptionEntity> types) {
this.types = types;
}
public Integer getMaxFileSizeInMB() {
return maxFileSizeInMB;
}
public void setMaxFileSizeInMB(Integer maxFileSizeInMB) {
this.maxFileSizeInMB = maxFileSizeInMB;
}
}

View File

@ -0,0 +1,66 @@
package org.opencdmp.commons.types.descriptiontemplate.importexport;
import org.opencdmp.commons.enums.DescriptionTemplateStatus;
import org.opencdmp.model.persist.DescriptionTemplatePersist;
import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist;
import org.opencdmp.model.persist.descriptiontemplatedefinition.DefinitionPersist;
import org.opencdmp.model.persist.descriptiontemplatedefinition.PagePersist;
import org.opencdmp.model.persist.descriptiontemplatedefinition.SectionPersist;
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
import jakarta.xml.bind.annotation.*;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
@XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateImportExport {
@XmlAttribute(name = "description")
private String description;
@XmlAttribute(name = "language")
private String language;
@XmlAttribute(name = "type")
private UUID type;
@XmlElementWrapper(name = "pages")
@XmlElement(name = "page")
private List<PageImportExport> pages;
public List<PageImportExport> getPages() {
return pages;
}
public void setPages(List<PageImportExport> pages) {
this.pages = pages;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public UUID getType() {
return type;
}
public void setType(UUID type) {
this.type = type;
}
}

Some files were not shown because too many files have changed in this diff Show More