Fixing a NPE.
parent
677a187618
commit
321d5b0337
|
|
@ -51,7 +51,7 @@ import javax.transaction.Transactional;
|
|||
public abstract class AbstractEntityImExporter<T extends Exportable> {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
|
|
@ -163,12 +163,12 @@ public abstract class AbstractEntityImExporter<T extends Exportable> {
|
|||
if (existingEntityResult.isPresent()) {
|
||||
final T existingEntity = existingEntityResult.get();
|
||||
updateExistingEntity(existingEntity, importedEntity);
|
||||
|
||||
|
||||
entityManager.flush();
|
||||
return existingEntity;
|
||||
} else {
|
||||
saveImportedEntity(importedEntity);
|
||||
|
||||
|
||||
entityManager.flush();
|
||||
return importedEntity;
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ public abstract class AbstractEntityImExporter<T extends Exportable> {
|
|||
/**
|
||||
* Reloads the entity to export. Entities become detacted for several
|
||||
* reasons before they are passed to the null null null null null null null
|
||||
* null null null null null null null {@link #exportEntity(org.libreccm.imexport.Exportable) method. The
|
||||
* null null null null null null null null {@link #exportEntity(org.libreccm.imexport.Exportable) method. The
|
||||
* implementation of this should reload the passed entity.
|
||||
*
|
||||
* @param entity The entity to reload.
|
||||
|
|
@ -278,6 +278,9 @@ public abstract class AbstractEntityImExporter<T extends Exportable> {
|
|||
final LocalizedString source,
|
||||
final LocalizedString target
|
||||
) {
|
||||
if (source == null || target == null) {
|
||||
return;
|
||||
}
|
||||
final Set<Locale> localesToAdd = source
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
|
|
@ -286,16 +289,6 @@ public abstract class AbstractEntityImExporter<T extends Exportable> {
|
|||
)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
final Set<Locale> localesToRemove = target
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
.filter(locale -> !source.getAvailableLocales().contains(locale))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (final Locale toRemove : localesToRemove) {
|
||||
target.removeValue(toRemove);
|
||||
}
|
||||
|
||||
for (final Locale toAdd : localesToAdd) {
|
||||
target.putValue(toAdd, source.getValue(toAdd));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue