Updated all ImExporters of ccm-core to implment new interface
parent
610b050ac5
commit
ef34c2b7f8
|
|
@ -19,11 +19,10 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
|
@ -31,7 +30,6 @@ import javax.enterprise.context.RequestScoped;
|
|||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Exporter/Importer for {@link TaskAssignment}s.
|
||||
|
|
@ -46,6 +44,9 @@ public class TaskAssignmentImExporter
|
|||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private TaskAssignmentRepository assignmentRepo;
|
||||
|
||||
@PostConstruct
|
||||
@Override
|
||||
|
|
@ -61,13 +62,25 @@ public class TaskAssignmentImExporter
|
|||
public Class<TaskAssignment> getEntityClass() {
|
||||
return TaskAssignment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Optional<TaskAssignment> findExistingEntity(final String uuid) {
|
||||
return assignmentRepo.findByUuid(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void saveImportedEntity(final TaskAssignment entity) {
|
||||
entityManager.persist(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateExistingEntity(
|
||||
final TaskAssignment exitingEntity,
|
||||
final TaskAssignment importedEntity
|
||||
) {
|
||||
// Task Assignment are not updated
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskAssignment reloadEntity(final TaskAssignment entity) {
|
||||
|
|
|
|||
|
|
@ -19,17 +19,14 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Importer/Exporter for {@link TaskComment}s.
|
||||
|
|
@ -54,12 +51,39 @@ public class TaskCommentImExporter extends AbstractEntityImExporter<TaskComment>
|
|||
public Class<TaskComment> getEntityClass() {
|
||||
return TaskComment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Optional<TaskComment> findExistingEntity(final String uuid) {
|
||||
return taskCommentRepository.findByUuid(uuid);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void saveImportedEntity(TaskComment entity) {
|
||||
taskCommentRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateExistingEntity(
|
||||
final TaskComment existingEntity,
|
||||
final TaskComment importedEntity
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingEntity.getComment(),
|
||||
importedEntity.getComment()
|
||||
)) {
|
||||
existingEntity.setComment(importedEntity.getComment());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingEntity.getAuthor(),
|
||||
importedEntity.getAuthor()
|
||||
)) {
|
||||
existingEntity.setAuthor(importedEntity.getAuthor());
|
||||
}
|
||||
|
||||
taskCommentRepository.save(existingEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskComment reloadEntity(final TaskComment entity) {
|
||||
|
|
|
|||
|
|
@ -19,11 +19,10 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
|
@ -46,6 +45,9 @@ public class TaskDependencyImExporter
|
|||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private TaskDependencyRepository taskDependencyRepo;
|
||||
|
||||
@PostConstruct
|
||||
@Override
|
||||
|
|
@ -61,13 +63,25 @@ public class TaskDependencyImExporter
|
|||
public Class<TaskDependency> getEntityClass() {
|
||||
return TaskDependency.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Optional<TaskDependency> findExistingEntity(final String uuid) {
|
||||
return taskDependencyRepo.findByUuid(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void saveImportedEntity(final TaskDependency entity) {
|
||||
entityManager.merge(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateExistingEntity(
|
||||
final TaskDependency existingEntity,
|
||||
final TaskDependency importedEntity
|
||||
) {
|
||||
// Task Dependencies are not updated.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskDependency reloadEntity(final TaskDependency entity) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue