Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-03-19 14:01:26 +02:00
commit 5f52e646a5
27 changed files with 269 additions and 93 deletions

View File

@ -70,7 +70,7 @@ public final class Permission {
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 CreateNewVersionDmp = "CreateNewVersionDmp";

View File

@ -33,9 +33,17 @@ public class ElasticConfiguration extends AbstractElasticConfiguration {
new DmpStatusToShortConverter(),
new DescriptionStatusToShortConverter(),
new IsActiveToShortConverter(),
new DescriptionTemplateVersionStatusToShortConverter(),
new DmpVersionStatusToShortConverter(),
new DmpAccessTypeToShortConverter()
new DmpAccessTypeToShortConverter(),
new ShortToDmpStatusConverter(),
new ShortToDmpUserRoleConverter(),
new ShortToDescriptionTemplateVersionStatusConverter(),
new ShortToDmpStatusConverter(),
new ShortToDescriptionStatusConverter(),
new ShortToIsActiveConverter(),
new ShortToDmpVersionStatusConverter(),
new ShortToDmpAccessTypeConverter()
));
}
}

View File

@ -1,6 +1,5 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.DmpStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@ -12,3 +11,4 @@ public class DmpStatusToShortConverter implements Converter<DmpStatus, Short> {
return source.getValue();
}
}

View File

@ -1,13 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class IsActiveToShortConverter implements Converter<DmpStatus, Short> {
public class IsActiveToShortConverter implements Converter<IsActive, Short> {
@Override
public Short convert(DmpStatus source) {
public Short convert(IsActive source) {
return source.getValue();
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DescriptionStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
@ReadingConverter
public class ShortToDescriptionStatusConverter implements Converter<Integer, DescriptionStatus> {
@Override
public DescriptionStatus convert(Integer source) {
return DescriptionStatus.of(source.shortValue());
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
@ReadingConverter
public class ShortToDescriptionTemplateVersionStatusConverter implements Converter<Integer, DescriptionTemplateVersionStatus> {
@Override
public DescriptionTemplateVersionStatus convert(Integer source) {
return DescriptionTemplateVersionStatus.of(source.shortValue());
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpAccessType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
@ReadingConverter
public class ShortToDmpAccessTypeConverter implements Converter<Integer, DmpAccessType> {
@Override
public DmpAccessType convert(Integer source) {
return DmpAccessType.of(source.shortValue());
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.*;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
@ReadingConverter
public class ShortToDmpStatusConverter implements Converter<Integer, DmpStatus> {
@Override
public DmpStatus convert(Integer source) {
return DmpStatus.of(source.shortValue());
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpUserRole;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
@ReadingConverter
public class ShortToDmpUserRoleConverter implements Converter<Integer, DmpUserRole> {
@Override
public DmpUserRole convert(Integer source) {
return DmpUserRole.of(source.shortValue());
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpVersionStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
@ReadingConverter
public class ShortToDmpVersionStatusConverter implements Converter<Integer, DmpVersionStatus> {
@Override
public DmpVersionStatus convert(Integer source) {
return DmpVersionStatus.of(source.shortValue());
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.IsActive;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
@ReadingConverter
public class ShortToIsActiveConverter implements Converter<Integer, IsActive> {
@Override
public IsActive convert(Integer source) {
return IsActive.of(source.shortValue());
}
}

View File

@ -208,12 +208,12 @@ public class DescriptionPersist {
.iff(() -> !this.isNull(item.getProperties()))
.on(DescriptionPersist._properties)
.over(item.getProperties())
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition)),
this.navSpec()
.iff(() -> !this.isNull(item.getTags()))
.on(DescriptionPersist._tags)
.over(item.getTags())
.using((itm) -> this.validatorFactory.validator(TagPersist.TagPersistValidator.class))
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition))
// this.navSpec()
// .iff(() -> !this.isNull(item.getTags()))
// .on(DescriptionPersist._tags)
// .over(item.getTags())
// .using((itm) -> this.validatorFactory.validator(TagPersist.TagPersistValidator.class))
);
}
}

View File

@ -103,9 +103,11 @@ public class PropertyDefinitionPersist {
boolean requiredAtLeastOneFieldSet = fieldSet.getMultiplicity() != null && fieldSet.getMultiplicity().getMin() > 0;
if (requiredAtLeastOneFieldSet) {
if (item == null || item.getFieldSets() == null) missingMultipleFieldSets.add(fieldSet);
if (item.getFieldSets() != null) {
PropertyDefinitionFieldSetPersist fieldSetPersist = item.getFieldSets().getOrDefault(fieldSet.getId(), null);
if (fieldSetPersist == null) missingMultipleFieldSets.add(fieldSet);
}
}
}
return missingMultipleFieldSets;

View File

@ -2,6 +2,7 @@ package eu.eudat.service.deposit;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver;
import eu.eudat.commonmodels.models.FileEnvelopeModel;
import eu.eudat.commonmodels.models.dmp.DmpModel;
import eu.eudat.commons.enums.StorageType;
@ -69,6 +70,7 @@ public class DepositServiceImpl implements DepositService {
private final ValidatorFactory validatorFactory;
private final StorageFileProperties storageFileProperties;
private final ConventionService conventionService;
private final AuthorizationContentResolver authorizationContentResolver;
@Autowired
public DepositServiceImpl(DepositProperties depositProperties,
TokenExchangeCacheService tokenExchangeCacheService,
@ -77,7 +79,7 @@ public class DepositServiceImpl implements DepositService {
EntityDoiService doiService,
QueryFactory queryFactory,
MessageSource messageSource,
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService, FileTransformerService fileTransformerService, StorageFileService storageFileService, UserScope userScope, ValidatorFactory validatorFactory, StorageFileProperties storageFileProperties, ConventionService conventionService) {
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService, FileTransformerService fileTransformerService, StorageFileService storageFileService, UserScope userScope, ValidatorFactory validatorFactory, StorageFileProperties storageFileProperties, ConventionService conventionService, AuthorizationContentResolver authorizationContentResolver) {
this.depositProperties = depositProperties;
this.tokenExchangeCacheService = tokenExchangeCacheService;
this.authorizationService = authorizationService;
@ -93,6 +95,7 @@ public class DepositServiceImpl implements DepositService {
this.validatorFactory = validatorFactory;
this.storageFileProperties = storageFileProperties;
this.conventionService = conventionService;
this.authorizationContentResolver = authorizationContentResolver;
this.clients = new HashMap<>();
}
@ -139,9 +142,7 @@ public class DepositServiceImpl implements DepositService {
@Override
public EntityDoi deposit(DepositRequest dmpDepositModel) throws Exception {
this.authorizationService.authorizeForce(Permission.EditDeposit);
this.authorizationService.authorize(Permission.EditDmp);
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(dmpDepositModel.getDmpId())), Permission.DepositDmp);
//GK: First get the right client
DepositClient depositClient = getDepositClient(dmpDepositModel.getRepositoryId());
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));

View File

@ -380,9 +380,8 @@ public class DescriptionServiceImpl implements DescriptionService {
for (DescriptionEntity description: descriptions) {
DescriptionValidationResult descriptionValidationResult = new DescriptionValidationResult(description.getId(), DescriptionValidationOutput.Invalid);
// // TODO Persist
DescriptionPersist.DescriptionPersistValidator validator = this.validatorFactory.validator(DescriptionPersist.DescriptionPersistValidator.class);
validator.validate(new DescriptionPersist());
validator.validate(this.buildDescriptionPersist(description));
if (validator.result().isValid()) descriptionValidationResult.setResult(DescriptionValidationOutput.Valid);;
descriptionValidationResults.add(descriptionValidationResult);
@ -836,4 +835,91 @@ public class DescriptionServiceImpl implements DescriptionService {
return storageFile;
}
//region build persist
private @NotNull DescriptionPersist buildDescriptionPersist(DescriptionEntity data){
DescriptionPersist persist = new DescriptionPersist();
if (data == null) return persist;
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId());
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
persist.setLabel(data.getLabel());
persist.setStatus(data.getStatus());
persist.setDescription(data.getDescription());
persist.setDescriptionTemplateId(data.getDescriptionTemplateId());
persist.setDmpId(data.getDmpId());
persist.setDmpDescriptionTemplateId(data.getDmpDescriptionTemplateId());
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
persist.setProperties(this.buildPropertyDefinitionPersist( this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, data.getProperties()), definition));
return persist;
}
private @NotNull PropertyDefinitionPersist buildPropertyDefinitionPersist(PropertyDefinitionEntity data, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition){
PropertyDefinitionPersist persist = new PropertyDefinitionPersist();
if (data == null) return persist;
if (data.getFieldSets() != null && !data.getFieldSets().isEmpty()){
persist.setFieldSets(new HashMap<>());
for (String key: data.getFieldSets().keySet()) {
FieldSetEntity fieldSetEntity = definition != null ? definition.getFieldSetById(key).stream().findFirst().orElse(null) : null;
persist.getFieldSets().put(key, this.buildPropertyDefinitionFieldSetPersist(data.getFieldSets().get(key), fieldSetEntity));
}
}
return persist;
}
private @NotNull PropertyDefinitionFieldSetPersist buildPropertyDefinitionFieldSetPersist(PropertyDefinitionFieldSetEntity data, FieldSetEntity fieldSetEntity){
PropertyDefinitionFieldSetPersist persist = new PropertyDefinitionFieldSetPersist();
if (data == null) return persist;
if (!this.conventionService.isListNullOrEmpty(data.getItems())){
persist.setItems(new ArrayList<>());
for (PropertyDefinitionFieldSetItemEntity itemsPersist: data.getItems()) {
persist.getItems().add(this.buildPropertyDefinitionFieldSetItemPersist(itemsPersist, fieldSetEntity));
}
}
return persist;
}
private @NotNull PropertyDefinitionFieldSetItemPersist buildPropertyDefinitionFieldSetItemPersist(PropertyDefinitionFieldSetItemEntity data, FieldSetEntity fieldSetEntity){
PropertyDefinitionFieldSetItemPersist persist = new PropertyDefinitionFieldSetItemPersist();
if (data == null) return persist;
if (data.getFields() != null && !data.getFields().isEmpty()){
persist.setOrdinal(data.getOrdinal());
persist.setComment(data.getComment());
persist.setFields(new HashMap<>());
for (String key: data.getFields().keySet()) {
eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getAllField().stream().findFirst().orElse(null) : null;
persist.getFields().put(key, this.buildFieldPersist(data.getFields().get(key), fieldEntity));
}
}
return persist;
}
private @NotNull FieldPersist buildFieldPersist(FieldEntity data, eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity) {
FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
FieldPersist persist = new FieldPersist();
if (data == null) return persist;
if (FieldType.isTextType(fieldType)) persist.setTextValue(data.getTextValue());
else if (FieldType.isTextListType(fieldType)) persist.setTextListValue(data.getTextListValue());
else if (FieldType.isDateType(fieldType)) persist.setDateValue(persist.getDateValue());
else if (FieldType.isExternalIdentifierType(fieldType) && data.getExternalIdentifier() != null) persist.setExternalIdentifier(this.buildExternalIdentifierPersist(data.getExternalIdentifier()));
else if (FieldType.isReferenceType(fieldType) && fieldEntity != null ) persist.setTextListValue(data.getTextListValue());
return persist;
}
private @NotNull ExternalIdentifierPersist buildExternalIdentifierPersist(ExternalIdentifierEntity data){
ExternalIdentifierPersist persist = new ExternalIdentifierPersist();
if (data == null) return persist;
persist.setIdentifier(data.getIdentifier());
persist.setType(data.getType());
return persist;
}
}

View File

@ -836,6 +836,9 @@ public class DmpServiceImpl implements DmpService {
if (description.getStatus().equals(DescriptionStatus.Finalized)){
throw new MyApplicationException("Description is already finalized");
}
if (this.descriptionService.validate(List.of(description.getId())).get(0).getResult().equals(DescriptionValidationOutput.Invalid)){
throw new MyApplicationException("Description is invalid");
}
description.setStatus(DescriptionStatus.Finalized);
description.setUpdatedAt(Instant.now());
description.setFinalizedAt(Instant.now());

View File

@ -284,11 +284,14 @@ public class ElasticServiceImpl implements ElasticService {
public void deleteDmp(DmpEntity dmp) throws IOException {
if (!this.enabled()) return;
this.ensureIndexes();
this.elasticsearchTemplate.delete(dmp.getId(), IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
DmpElasticEntity dmpElasticEntity = this.elasticsearchTemplate.get(dmp.getId().toString(),DmpElasticEntity.class, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
if (dmpElasticEntity == null) return;
this.elasticsearchTemplate.delete(dmpElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).dmpSubQuery(this.queryFactory.query(DmpQuery.class).ids(dmp.getId())).collectAs(new BaseFieldSet().ensure(Description._id));
for (DescriptionEntity description: descriptions) {
this.elasticsearchTemplate.delete(description.getId(), IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
DescriptionElasticEntity descriptionElasticEntity = this.elasticsearchTemplate.get(description.getId().toString(), DescriptionElasticEntity.class, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
if (descriptionElasticEntity == null) continue;
this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
}
}
@ -312,7 +315,10 @@ public class ElasticServiceImpl implements ElasticService {
if (!this.enabled()) return;
this.ensureIndexes();
this.elasticsearchTemplate.delete(description.getId(), IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
DescriptionElasticEntity descriptionElasticEntity = this.elasticsearchTemplate.get(description.getId().toString(), DescriptionElasticEntity.class, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
if (descriptionElasticEntity == null) return;
this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId());
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (dmpEntity.getIsActive().equals(IsActive.Active)) {

View File

@ -1,4 +1,4 @@
package eu.eudat.cache.transformer;
package eu.eudat.service.transformer;
import eu.eudat.configurations.deposit.DepositCacheOptions;

View File

@ -2,7 +2,6 @@ package eu.eudat.service.transformer;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.cache.transformer.FileTransformerConfigurationCache;
import eu.eudat.commonmodels.models.FileEnvelopeModel;
import eu.eudat.commonmodels.models.description.DescriptionModel;
import eu.eudat.commonmodels.models.dmp.DmpModel;

View File

@ -1,52 +0,0 @@
//package eu.eudat.utilities.pdf;
//
//import eu.eudat.model.file.FileEnvelope;
//import org.apache.commons.io.IOUtils;
//import org.springframework.core.env.Environment;
//import org.springframework.core.io.FileSystemResource;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.web.client.RestTemplate;
//
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.nio.file.Files;
//import java.util.UUID;
//
//public class PDFUtils {
//
// public static File convertToPDF(eu.eudat.depositinterface.models.FileEnvelope file, Environment environment) throws IOException {
// FileEnvelope envelope = new FileEnvelope();
// envelope.setFilename(file.getFilename());
//// envelope.setFile(file.getFile());
// return convertToPDF(envelope, environment);
// }
//
// public static File convertToPDF(FileEnvelope file, Environment environment) throws IOException {
// LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
// String uuid = UUID.randomUUID().toString();
// map.add("files", new FileSystemResource(file.getFile()));
// map.add("filename", uuid + ".pdf");
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.MULTIPART_FORM_DATA);
// headers.add("Content-disposition", "attachment; filename=" + uuid + ".pdf");
// headers.add("Content-type", "application/pdf");
//
// HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(
// map, headers);
//
// byte[] queueResult = new RestTemplate().postForObject(environment.getProperty("pdf.converter.url") + "forms/libreoffice/convert"
// , requestEntity, byte[].class);
//
// File resultPdf = new File(environment.getProperty("temp.temp") + uuid + ".pdf");
// FileOutputStream output = new FileOutputStream(resultPdf);
// IOUtils.write(queueResult, output);
// output.close();
// Files.deleteIfExists(file.getFile().toPath());
//
// return resultPdf;
// }
//}

View File

@ -56,7 +56,7 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.7.0</version>
<version>8.5.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
@ -412,6 +412,19 @@
</property>
</activation>
</profile>
<profile>
<id>cite-dev</id>
<repositories>
<repository>
<id>cite-maven</id>
<name>CITE Maven Repository</name>
<url>https://crepo.cite.gr/repository/cite-maven/</url>
</repository>
</repositories>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</project>

View File

@ -387,6 +387,19 @@ permissions:
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
DepositDmp:
roles:
- Admin
dmp:
roles:
- Owner
- User
- DescriptionContributor
- Reviewer
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
CloneDmp:
roles:
- Admin

View File

@ -21,6 +21,7 @@ export enum AppPermission {
EditDmp = "EditDmp",
NewDmp = "NewDmp",
DeleteDmp = "DeleteDmp",
DepositDmp = "DepositDmp",
CloneDmp = "CloneDmp",
CreateNewVersionDmp = "CreateNewVersionDmp",
ExportDmp = "ExportDmp",

View File

@ -248,8 +248,4 @@ export class DmpService {
}
return dmpUserRoles;
}
isDmpOwner(dmpUsers: DmpUser[]): Boolean {
return this.getCurrentUserRolesInDmp(dmpUsers).includes(DmpUserRole.Owner);
}
}

View File

@ -36,7 +36,7 @@
</ng-container>
:</span>
{{ description.label }}
<i *ngIf="isDescriptionValid(description.id)" class="fa fa-spinner fa-spin" ></i>
<i *ngIf="!isDescriptionValid(description.id)" class="fa fa-spinner fa-spin" ></i>
</h4>
<h4 *ngIf="description.status == descriptionStatusEnum.Finalized" class="col-11 ml-auto mt-1 mb-4">{{ description.label }}</h4>
</div>

View File

@ -144,8 +144,8 @@
<hr class="hr-line">
</div>
</div>
<app-dmp-deposit-dropdown *ngIf="(hasDoi(dmp) || moreDeposit()) && isFinalizedDmp(dmp) && !this.isPublicView && isDmpOwner(dmp) && inputRepos.length > 0" [inputRepos]="inputRepos" [dmp]="dmp" (outputReposEmitter)="afterDeposit($event)"></app-dmp-deposit-dropdown>
<div *ngIf="isFinalizedDmp(dmp) && hasDoi(dmp) && !isPublishedDmp(dmp) && isDmpOwner(dmp)" (click)="reverseFinalization()" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center">
<app-dmp-deposit-dropdown *ngIf="(hasDoi(dmp) || moreDeposit()) && isFinalizedDmp(dmp) && !this.isPublicView && canDepositDmp(dmp) && inputRepos.length > 0" [inputRepos]="inputRepos" [dmp]="dmp" (outputReposEmitter)="afterDeposit($event)"></app-dmp-deposit-dropdown>
<div *ngIf="isFinalizedDmp(dmp) && hasDoi(dmp) && !isPublishedDmp(dmp) && canFinalizeDmp(dmp)" (click)="reverseFinalization()" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center">
<button mat-mini-fab class="frame-btn">
<mat-icon class="mat-mini-fab-icon">unarchive</mat-icon>
</button>

View File

@ -202,11 +202,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} else return false;
}
isDmpOwner(): boolean {
const principalId: Guid = this.authentication.userId();
if (principalId) return !!this.dmp.dmpUsers?.find(x => (x.role === DmpUserRole.Owner) && (principalId === x.user?.id));
}
canEditDmp(): boolean{
return (this.isDraftDmp()) && (this.dmp.authorizationFlags?.some(x => x === AppPermission.EditDmp) || this.authentication.hasPermission(AppPermission.EditDmp)) && this.isPublicView == false;
}
@ -239,6 +234,11 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.AssignDmpUsers) || this.authentication.hasPermission(AppPermission.AssignDmpUsers) && this.isPublicView == false;
}
canDepositDmp(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.DepositDmp) || this.authentication.hasPermission(AppPermission.DepositDmp) && this.isPublicView == false;
}
editClicked() {
this.router.navigate(['/plans/edit/', this.dmp.id]);
}
@ -741,6 +741,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.InviteDmpUsers].join('.'),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.AssignDmpUsers].join('.'),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.EditDmp].join('.'),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.DepositDmp].join('.'),
[nameof<Dmp>(x => x.entityDois), nameof<EntityDoi>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.entityDois), nameof<EntityDoi>(x => x.repositoryId)].join('.'),
[nameof<Dmp>(x => x.entityDois), nameof<EntityDoi>(x => x.doi)].join('.'),