Compare commits

..

3 Commits

10 changed files with 31 additions and 45 deletions

View File

@ -161,7 +161,7 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel,
this.logger.debug("checking related - {}", TagEntity.class.getSimpleName()); this.logger.debug("checking related - {}", TagEntity.class.getSimpleName());
List<UUID> tagIds = data.stream().map(FieldEntity::getTextListValue).filter(Objects::nonNull).flatMap(List::stream).filter(x-> !this.conventionService.isNullOrEmpty(x)).map(UUID::fromString).distinct().collect(Collectors.toList()); List<UUID> tagIds = data.stream().map(FieldEntity::getTextListValue).filter(Objects::nonNull).flatMap(List::stream).filter(x-> !this.conventionService.isNullOrEmpty(x)).map(UUID::fromString).distinct().collect(Collectors.toList());
List<TagEntity> existingTags = this.queryFactory.query(TagQuery.class).authorize(AuthorizationFlags.AllExceptPublic).disableTracking().ids(tagIds).collectAs(new BaseFieldSet().ensure(Tag._id).ensure(Tag._label)); List<TagEntity> existingTags = this.queryFactory.query(TagQuery.class).authorize(this.authorize).disableTracking().ids(tagIds).collectAs(new BaseFieldSet().ensure(Tag._id).ensure(Tag._label));
Map<UUID, String> itemMap = new HashMap<>(); Map<UUID, String> itemMap = new HashMap<>();
for (UUID tag : tagIds){ for (UUID tag : tagIds){

View File

@ -6,10 +6,9 @@ import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.enums.PlanVersionStatus;
import org.opencdmp.commons.enums.EntityType; import org.opencdmp.commons.enums.EntityType;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.PlanVersionStatus;
import org.opencdmp.data.*; import org.opencdmp.data.*;
import org.opencdmp.model.PlanDescriptionTemplate; import org.opencdmp.model.PlanDescriptionTemplate;
import org.opencdmp.model.description.Description; import org.opencdmp.model.description.Description;
@ -104,7 +103,7 @@ public class PlanDeleter implements Deleter {
for (PlanEntity item : data) { for (PlanEntity item : data) {
logger.trace("deleting item {}", item.getId()); logger.trace("deleting item {}", item.getId());
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.Plan).entityIds(item.getId()); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).types(EntityType.Plan).entityIds(item.getId());
if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited can not deleted"); if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited can not deleted");
if(item.getVersionStatus().equals(PlanVersionStatus.Current)) throw new MyApplicationException("Plan is current can not deleted"); if(item.getVersionStatus().equals(PlanVersionStatus.Current)) throw new MyApplicationException("Plan is current can not deleted");
item.setIsActive(IsActive.Inactive); item.setIsActive(IsActive.Inactive);

View File

@ -3,7 +3,6 @@ package org.opencdmp.model.persist;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
@ -245,7 +244,7 @@ public class DescriptionPersist {
PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(planDescriptionTemplateId).isActive(IsActive.Active).planIds(planId).first(); PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(planDescriptionTemplateId).isActive(IsActive.Active).planIds(planId).first();
if (planDescriptionTemplateEntity == null) return true; if (planDescriptionTemplateEntity == null) return true;
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect(); List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect();
for (SectionEntity section: definition.getSections()) { for (SectionEntity section: definition.getSections()) {
if (planDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ if (planDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){

View File

@ -3,7 +3,6 @@ package org.opencdmp.model.persist;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.XmlHandlingService; import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.enums.*; import org.opencdmp.commons.enums.*;
import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
@ -274,8 +273,8 @@ public class PlanPersist {
org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition()); org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition());
if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true; if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true;
List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).planIds(planId).collect(); List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).planIds(planId).collect();
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).isActive(IsActive.Active).collect(); List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).isActive(IsActive.Active).collect();
for (SectionEntity section: definition.getSections()) { for (SectionEntity section: definition.getSections()) {
if (section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ if (section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){

View File

@ -1,10 +1,8 @@
package org.opencdmp.model.persist.planproperties; package org.opencdmp.model.persist.planproperties;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType; import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType;
import org.opencdmp.commons.enums.PlanBlueprintFieldCategory; import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
import org.opencdmp.commons.types.planblueprint.DefinitionEntity; import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
@ -15,8 +13,6 @@ import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.opencdmp.model.persist.ReferencePersist; import org.opencdmp.model.persist.ReferencePersist;
import org.opencdmp.model.referencetype.ReferenceType;
import org.opencdmp.query.ReferenceTypeQuery;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -169,13 +165,6 @@ public class PlanBlueprintValuePersist {
this.definition = definition; this.definition = definition;
return this; return this;
} }
private String getReferenceTypeName(FieldEntity fieldEntity){
if (fieldEntity instanceof ReferenceTypeFieldEntity) {
return this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(((ReferenceTypeFieldEntity)fieldEntity).getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._name)).getName();
}
return "";
}
} }
} }

View File

@ -311,7 +311,7 @@ public class DepositServiceImpl implements DepositService {
} }
//GK: Fifth Transform them to the DepositModel //GK: Fifth Transform them to the DepositModel
PlanModel depositModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.AllExceptPublic) PlanModel depositModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.All)
.setRepositoryId(planDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(planEntity); .setRepositoryId(planDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(planEntity);

View File

@ -60,13 +60,13 @@ import org.opencdmp.model.deleter.DescriptionReferenceDeleter;
import org.opencdmp.model.deleter.DescriptionTagDeleter; import org.opencdmp.model.deleter.DescriptionTagDeleter;
import org.opencdmp.model.description.Description; import org.opencdmp.model.description.Description;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.file.FileEnvelope; import org.opencdmp.model.file.FileEnvelope;
import org.opencdmp.model.persist.*; import org.opencdmp.model.persist.*;
import org.opencdmp.model.persist.descriptionproperties.*; import org.opencdmp.model.persist.descriptionproperties.*;
import org.opencdmp.model.persist.descriptionreference.DescriptionReferenceDataPersist; import org.opencdmp.model.persist.descriptionreference.DescriptionReferenceDataPersist;
import org.opencdmp.model.persist.referencedefinition.DefinitionPersist; import org.opencdmp.model.persist.referencedefinition.DefinitionPersist;
import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.reference.Reference; import org.opencdmp.model.reference.Reference;
import org.opencdmp.model.referencetype.ReferenceType; import org.opencdmp.model.referencetype.ReferenceType;
import org.opencdmp.query.*; import org.opencdmp.query.*;
@ -294,7 +294,7 @@ public class DescriptionServiceImpl implements DescriptionService {
PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(planDescriptionTemplateId).isActive(IsActive.Active).planIds(planId).first(); PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(planDescriptionTemplateId).isActive(IsActive.Active).planIds(planId).first();
if (planDescriptionTemplateEntity == null) return true; if (planDescriptionTemplateEntity == null) return true;
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect(); List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect();
for (SectionEntity section: definition.getSections()) { for (SectionEntity section: definition.getSections()) {
if (planDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){ if (planDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){
@ -501,7 +501,7 @@ public class DescriptionServiceImpl implements DescriptionService {
public List<DescriptionValidationResult> validate(List<UUID> descriptionIds) throws InvalidApplicationException { public List<DescriptionValidationResult> validate(List<UUID> descriptionIds) throws InvalidApplicationException {
List<DescriptionValidationResult> descriptionValidationResults = new ArrayList<>(); List<DescriptionValidationResult> descriptionValidationResults = new ArrayList<>();
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(descriptionIds).isActive(IsActive.Active).collect(); List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(descriptionIds).isActive(IsActive.Active).collect();
if (descriptions == null){ if (descriptions == null){
return null; return null;
} }

View File

@ -44,12 +44,12 @@ import org.opencdmp.model.builder.commonmodels.descriptiontemplate.DescriptionTe
import org.opencdmp.model.builder.commonmodels.plan.PlanCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.plan.PlanCommonModelBuilder;
import org.opencdmp.model.builder.commonmodels.planblueprint.PlanBlueprintCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.planblueprint.PlanBlueprintCommonModelBuilder;
import org.opencdmp.model.description.Description; import org.opencdmp.model.description.Description;
import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.file.RepositoryFileFormat; import org.opencdmp.model.file.RepositoryFileFormat;
import org.opencdmp.model.persist.DescriptionCommonModelConfig; import org.opencdmp.model.persist.DescriptionCommonModelConfig;
import org.opencdmp.model.persist.PlanCommonModelConfig; import org.opencdmp.model.persist.PlanCommonModelConfig;
import org.opencdmp.model.persist.StorageFilePersist; import org.opencdmp.model.persist.StorageFilePersist;
import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.tenantconfiguration.TenantConfiguration; import org.opencdmp.model.tenantconfiguration.TenantConfiguration;
import org.opencdmp.query.*; import org.opencdmp.query.*;
import org.opencdmp.service.encryption.EncryptionService; import org.opencdmp.service.encryption.EncryptionService;
@ -259,7 +259,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
//GK: Second get the Target Data Management Plan //GK: Second get the Target Data Management Plan
PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(planId); PlanQuery query = this.queryFactory.query(PlanQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(planId);
PlanModel planFileTransformerModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.AllExceptPublic).build(query.first()); PlanModel planFileTransformerModel = this.builderFactory.builder(PlanCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.All).build(query.first());
if (planFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (planFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planId, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale()));
FileEnvelopeModel fileEnvelope = repository.exportPlan(planFileTransformerModel, format); FileEnvelopeModel fileEnvelope = repository.exportPlan(planFileTransformerModel, format);
@ -280,7 +280,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
//GK: Second get the Target Data Management Plan //GK: Second get the Target Data Management Plan
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(descriptionId); DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(descriptionId);
DescriptionModel descriptionFileTransformerModel = this.builderFactory.builder(DescriptionCommonModelBuilder.class).setRepositoryId(repository.getConfiguration().getFileTransformerId()).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.AllExceptPublic).build(query.first()); DescriptionModel descriptionFileTransformerModel = this.builderFactory.builder(DescriptionCommonModelBuilder.class).setRepositoryId(repository.getConfiguration().getFileTransformerId()).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.All).build(query.first());
if (descriptionFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionId, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (descriptionFileTransformerModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionId, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
FileEnvelopeModel fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format); FileEnvelopeModel fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format);
@ -316,7 +316,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
public PlanModel importPlan(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException { public PlanModel importPlan(PlanCommonModelConfig planCommonModelConfig) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException {
this.authorizationService.authorizeForce(Permission.NewPlan); this.authorizationService.authorizeForce(Permission.NewPlan);
StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getFileId()).first(); StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(planCommonModelConfig.getFileId()).first();
if (tempFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getFileId(), StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (tempFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getFileId(), StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -324,15 +324,15 @@ public class FileTransformerServiceImpl implements FileTransformerService {
FileTransformerRepository repository = this.getRepository(planCommonModelConfig.getRepositoryId()); FileTransformerRepository repository = this.getRepository(planCommonModelConfig.getRepositoryId());
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getRepositoryId(), FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getRepositoryId(), FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
PlanBlueprintQuery planBlueprintQuery = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getBlueprintId()); PlanBlueprintQuery planBlueprintQuery = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(planCommonModelConfig.getBlueprintId());
PlanBlueprintModel planBlueprintModel = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(planBlueprintQuery.first()); PlanBlueprintModel planBlueprintModel = this.builderFactory.builder(PlanBlueprintCommonModelBuilder.class).authorize(AuthorizationFlags.All).build(planBlueprintQuery.first());
if (planBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (planBlueprintModel == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{planCommonModelConfig.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
PlanImportModel planImportModel = new PlanImportModel(); PlanImportModel planImportModel = new PlanImportModel();
planImportModel.setBlueprintModel(planBlueprintModel); planImportModel.setBlueprintModel(planBlueprintModel);
if (!this.conventionService.isListNullOrEmpty(planCommonModelConfig.getDescriptions())){ if (!this.conventionService.isListNullOrEmpty(planCommonModelConfig.getDescriptions())){
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(planCommonModelConfig.getDescriptions().stream().map(x -> x.getTemplateId()).distinct().collect(Collectors.toList())).collect(); List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(planCommonModelConfig.getDescriptions().stream().map(DescriptionCommonModelConfig::getTemplateId).distinct().collect(Collectors.toList())).collect();
if (descriptionTemplateEntities == null) throw new MyApplicationException("Description Templates Not Exist!"); if (descriptionTemplateEntities == null) throw new MyApplicationException("Description Templates Not Exist!");
@ -340,7 +340,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
for (DescriptionCommonModelConfig descriptionCommonModelConfig : planCommonModelConfig.getDescriptions()) { for (DescriptionCommonModelConfig descriptionCommonModelConfig : planCommonModelConfig.getDescriptions()) {
DescriptionTemplateEntity descriptionTemplateEntity = descriptionTemplateEntities.stream().filter(x -> x.getId().equals(descriptionCommonModelConfig.getTemplateId())).findFirst().orElse(null); DescriptionTemplateEntity descriptionTemplateEntity = descriptionTemplateEntities.stream().filter(x -> x.getId().equals(descriptionCommonModelConfig.getTemplateId())).findFirst().orElse(null);
if (descriptionTemplateEntity != null){ if (descriptionTemplateEntity != null){
DescriptionTemplateModel descriptionTemplateModel = this.builderFactory.builder(DescriptionTemplateCommonModelBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(descriptionTemplateEntity); DescriptionTemplateModel descriptionTemplateModel = this.builderFactory.builder(DescriptionTemplateCommonModelBuilder.class).authorize(AuthorizationFlags.All).build(descriptionTemplateEntity);
DescriptionImportModel descriptionImportModel = new DescriptionImportModel(); DescriptionImportModel descriptionImportModel = new DescriptionImportModel();
descriptionImportModel.setId(descriptionCommonModelConfig.getId()); descriptionImportModel.setId(descriptionCommonModelConfig.getId());
@ -383,7 +383,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
public PreprocessingPlanModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException { public PreprocessingPlanModel preprocessingPlan(UUID fileId, String repositoryId) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException {
this.authorizationService.authorizeForce(Permission.NewPlan); this.authorizationService.authorizeForce(Permission.NewPlan);
StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(fileId).first(); StorageFileEntity tempFile = this.queryFactory.query(StorageFileQuery.class).disableTracking().authorize(AuthorizationFlags.All).ids(fileId).first();
if (tempFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{fileId, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (tempFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{fileId, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));

View File

@ -44,6 +44,7 @@ import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.commons.types.actionconfirmation.PlanInvitationEntity; import org.opencdmp.commons.types.actionconfirmation.PlanInvitationEntity;
import org.opencdmp.commons.types.description.importexport.DescriptionImportExport; import org.opencdmp.commons.types.description.importexport.DescriptionImportExport;
import org.opencdmp.commons.types.notification.*;
import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity; import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity;
import org.opencdmp.commons.types.plan.PlanContactEntity; import org.opencdmp.commons.types.plan.PlanContactEntity;
import org.opencdmp.commons.types.plan.PlanPropertiesEntity; import org.opencdmp.commons.types.plan.PlanPropertiesEntity;
@ -56,14 +57,13 @@ import org.opencdmp.commons.types.planblueprint.importexport.BlueprintExtraField
import org.opencdmp.commons.types.planblueprint.importexport.BlueprintReferenceTypeFieldImportExport; import org.opencdmp.commons.types.planblueprint.importexport.BlueprintReferenceTypeFieldImportExport;
import org.opencdmp.commons.types.planblueprint.importexport.BlueprintSectionImportExport; import org.opencdmp.commons.types.planblueprint.importexport.BlueprintSectionImportExport;
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity; import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
import org.opencdmp.commons.types.notification.*;
import org.opencdmp.commons.types.reference.DefinitionEntity; import org.opencdmp.commons.types.reference.DefinitionEntity;
import org.opencdmp.commons.types.reference.FieldEntity; import org.opencdmp.commons.types.reference.FieldEntity;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.*; import org.opencdmp.data.*;
import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.opencdmp.event.PlanTouchedEvent;
import org.opencdmp.event.EventBroker; import org.opencdmp.event.EventBroker;
import org.opencdmp.event.PlanTouchedEvent;
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel; import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler;
import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
@ -77,9 +77,6 @@ import org.opencdmp.model.builder.plan.PlanBuilder;
import org.opencdmp.model.deleter.*; import org.opencdmp.model.deleter.*;
import org.opencdmp.model.description.Description; import org.opencdmp.model.description.Description;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate; import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.planreference.PlanReferenceData;
import org.opencdmp.model.file.FileEnvelope; import org.opencdmp.model.file.FileEnvelope;
import org.opencdmp.model.persist.*; import org.opencdmp.model.persist.*;
import org.opencdmp.model.persist.actionconfirmation.PlanInvitationPersist; import org.opencdmp.model.persist.actionconfirmation.PlanInvitationPersist;
@ -89,15 +86,18 @@ import org.opencdmp.model.persist.planproperties.PlanPropertiesPersist;
import org.opencdmp.model.persist.planreference.PlanReferenceDataPersist; import org.opencdmp.model.persist.planreference.PlanReferenceDataPersist;
import org.opencdmp.model.persist.referencedefinition.DefinitionPersist; import org.opencdmp.model.persist.referencedefinition.DefinitionPersist;
import org.opencdmp.model.persist.referencedefinition.FieldPersist; import org.opencdmp.model.persist.referencedefinition.FieldPersist;
import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.planreference.PlanReferenceData;
import org.opencdmp.model.reference.Reference; import org.opencdmp.model.reference.Reference;
import org.opencdmp.model.referencetype.ReferenceType; import org.opencdmp.model.referencetype.ReferenceType;
import org.opencdmp.query.*; import org.opencdmp.query.*;
import org.opencdmp.service.actionconfirmation.ActionConfirmationService; import org.opencdmp.service.actionconfirmation.ActionConfirmationService;
import org.opencdmp.service.description.DescriptionService; import org.opencdmp.service.description.DescriptionService;
import org.opencdmp.service.descriptiontemplate.DescriptionTemplateService; import org.opencdmp.service.descriptiontemplate.DescriptionTemplateService;
import org.opencdmp.service.planblueprint.PlanBlueprintService;
import org.opencdmp.service.elastic.ElasticService; import org.opencdmp.service.elastic.ElasticService;
import org.opencdmp.service.filetransformer.FileTransformerService; import org.opencdmp.service.filetransformer.FileTransformerService;
import org.opencdmp.service.planblueprint.PlanBlueprintService;
import org.opencdmp.service.responseutils.ResponseUtilsService; import org.opencdmp.service.responseutils.ResponseUtilsService;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -264,7 +264,7 @@ public class PlanServiceImpl implements PlanService {
} }
private void checkIfDescriptionTemplateIsUse (List<PlanDescriptionTemplatePersist> descriptionTemplates, UUID id){ private void checkIfDescriptionTemplateIsUse (List<PlanDescriptionTemplatePersist> descriptionTemplates, UUID id){
List<PlanDescriptionTemplateEntity> existingPlanDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(id).isActive(IsActive.Active).collect(); List<PlanDescriptionTemplateEntity> existingPlanDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().planIds(id).isActive(IsActive.Active).collect();
List<PlanDescriptionTemplateEntity> removedDescriptionTemplates = existingPlanDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).toList(); List<PlanDescriptionTemplateEntity> removedDescriptionTemplates = existingPlanDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).toList();
PlanDescriptionTemplateQuery planDescriptionTemplateQuery = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).planIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(PlanDescriptionTemplateEntity::getDescriptionTemplateGroupId).collect(Collectors.toList())); PlanDescriptionTemplateQuery planDescriptionTemplateQuery = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).planIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(PlanDescriptionTemplateEntity::getDescriptionTemplateGroupId).collect(Collectors.toList()));
@ -354,7 +354,7 @@ public class PlanServiceImpl implements PlanService {
PlanEntity data = this.entityManager.find(PlanEntity.class, id); PlanEntity data = this.entityManager.find(PlanEntity.class, id);
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale()));
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.Plan).entityIds(data.getId()); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().types(EntityType.Plan).entityIds(data.getId());
if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited can not deleted"); if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited can not deleted");
PlanEntity previousPlan = null; PlanEntity previousPlan = null;
@ -1201,7 +1201,7 @@ public class PlanServiceImpl implements PlanService {
if (!plan.getStatus().equals(PlanStatus.Finalized)) throw new MyApplicationException("Plan is already drafted"); if (!plan.getStatus().equals(PlanStatus.Finalized)) throw new MyApplicationException("Plan is already drafted");
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.Plan).entityIds(plan.getId()).isActive(IsActive.Active); EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).types(EntityType.Plan).entityIds(plan.getId()).isActive(IsActive.Active);
if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited"); if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited");
plan.setStatus(PlanStatus.Draft); plan.setStatus(PlanStatus.Draft);

View File

@ -95,7 +95,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
if (d == null) if (d == null)
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale())); throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale()));
} else { } else {
List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).languageCodes(model.getLanguageCode()).types(model.getType()).collect(); List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).disableTracking().languageCodes(model.getLanguageCode()).types(model.getType()).collect();
if(data != null && !data.isEmpty()){ if(data != null && !data.isEmpty()){
throw new MyApplicationException("Could not create a new Data with same type and lang code !"); throw new MyApplicationException("Could not create a new Data with same type and lang code !");