Improved structure of PublicationImExporters
parent
786922c336
commit
0818ad1481
|
|
@ -3,7 +3,9 @@ package org.scientificcms.publications;
|
|||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
|
|
@ -17,6 +19,19 @@ public abstract class AbstractPublicationImExporter<T extends Publication>
|
|||
@Inject
|
||||
private PublicationRepository publicationRepo;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected final void init() {
|
||||
initPublicationImExporter();
|
||||
}
|
||||
|
||||
protected abstract void initPublicationImExporter();
|
||||
|
||||
@Override
|
||||
protected Optional<T> findExistingEntity(final String uuid) {
|
||||
return publicationRepo.findByUuidAndType(uuid, getEntityClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveImportedEntity(final Publication publication) {
|
||||
publicationRepo.save(publication);
|
||||
|
|
@ -100,7 +115,7 @@ public abstract class AbstractPublicationImExporter<T extends Publication>
|
|||
importedEntity.getLanguageOfPublication()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
updateExistingPublication(existingEntity, importedEntity);
|
||||
|
||||
publicationRepo.save(existingEntity);
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ import javax.annotation.PostConstruct;
|
|||
public abstract class AbstractPublicationWithPublisherImExporter<T extends PublicationWithPublisher>
|
||||
extends AbstractPublicationImExporter<T> {
|
||||
|
||||
@PostConstruct
|
||||
@Override
|
||||
protected final void init() {
|
||||
protected final void initPublicationImExporter() {
|
||||
addRequiredEntities(
|
||||
Set.of(
|
||||
Publisher.class
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import org.librecms.assets.Organization;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
|
|
@ -14,14 +12,15 @@ import javax.annotation.PostConstruct;
|
|||
public abstract class AbstractUnPublishedImExporter<T extends UnPublished>
|
||||
extends AbstractPublicationImExporter<T> {
|
||||
|
||||
@PostConstruct
|
||||
@Override
|
||||
protected final void init() {
|
||||
protected final void initPublicationImExporter() {
|
||||
addRequiredEntities(
|
||||
Set.of(Organization.class)
|
||||
);
|
||||
|
||||
initUnPublishedImExporter();
|
||||
}
|
||||
|
||||
|
||||
protected abstract void initUnPublishedImExporter();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue