Code reformatting and cleanup

deploy_packages_to_gitea
Jens Pelzetter 2022-09-24 11:11:33 +02:00
parent c65c182e14
commit c77dc2f991
16 changed files with 460 additions and 304 deletions

View File

@ -26,42 +26,51 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used by the {@link CategorizationImExporter} to resolve categories based on
* their UUIDs.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class CategoryIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -5750627754502675522L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey,
Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey idKey,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final CategoryRepository categoryRepository = cdiUtil
.findBean(CategoryRepository.class);
return categoryRepository
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return CdiUtil
.createCdiUtil()
.findBean(CategoryRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Category with uuid %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Category with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
public ObjectIdResolver newForDeserialization(Object context) {
public ObjectIdResolver newForDeserialization(final Object context) {
return new CategoryIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof CategoryIdResolver;
}
}

View File

@ -26,41 +26,50 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
* Used to resolve {@link Domain}s for import/export based on their UUIDs.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class DomainIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -8504371142795445708L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
public void bindItem(
final ObjectIdGenerator.IdKey idKey,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final DomainRepository domainRepository = cdiUtil
.findBean(DomainRepository.class);
return domainRepository
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return CdiUtil
.createCdiUtil()
.findBean(DomainRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Domain with uuid %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Domain with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
public ObjectIdResolver newForDeserialization(final Object context) {
return new DomainIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof DomainIdResolver;
}
}

View File

@ -26,32 +26,41 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
* Used to resolve {@link CcmObject}s based on their UUIDs when importing and
* exporting them.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class CcmObjectIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = 246452778202614974L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey,
Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey idKey,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final CcmObjectRepository ccmObjectRepository = cdiUtil
.findBean(CcmObjectRepository.class);
return ccmObjectRepository
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return CdiUtil
.createCdiUtil()
.findBean(CcmObjectRepository.class)
.findObjectByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No CcmObject with uuid %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No CcmObject with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
@ -63,4 +72,5 @@ public class CcmObjectIdResolver implements Serializable, ObjectIdResolver {
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof CcmObjectIdResolver;
}
}

View File

@ -26,40 +26,52 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
* Used to resolve {@link Resource}s based on their UUID when import or
* exporting them.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
*/
@RequestScoped
public class ResourceIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -402304483886269532L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
public void bindItem(
final ObjectIdGenerator.IdKey idKey,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ResourceRepository resourceRepository = cdiUtil
.findBean(ResourceRepository.class);
return resourceRepository
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return CdiUtil
.createCdiUtil()
.findBean(ResourceRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Resource with uuid %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Resource with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
public ObjectIdResolver newForDeserialization(final Object context) {
return new ResourceIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof ResourceIdResolver;
}
}

View File

@ -26,41 +26,51 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
* Used to resolve {@link ResourceType}s based in their UUID when importing or
* exporting them.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class ResourceTypeIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -3756063950193704821L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
public void bindItem(
final ObjectIdGenerator.IdKey idKey,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ResourceTypeRepository resourceTypeRepository = cdiUtil
.findBean(ResourceTypeRepository.class);
return resourceTypeRepository
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return CdiUtil
.createCdiUtil()
.findBean(ResourceTypeRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No ResourceType with uuid %s in the " +
"database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ResourceType with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
public ObjectIdResolver newForDeserialization(final Object context) {
return new ResourceTypeIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof ResourceTypeIdResolver;
}
}

View File

@ -110,14 +110,19 @@ public class ImportExport {
*/
@Transactional(Transactional.TxType.REQUIRED)
public void exportEntities(
final Collection<Exportable> entities, final String exportName
final Collection<Exportable> entities,
final String exportName
) {
final JsonObjectBuilder manifestBuilder = Json.createObjectBuilder();
manifestBuilder.add("created",
LocalDateTime.now(ZoneId.of("UTC")).toString());
manifestBuilder.add(
"created",
LocalDateTime.now(ZoneId.of("UTC")).toString()
);
try {
manifestBuilder.add("onServer",
InetAddress.getLocalHost().getHostName());
manifestBuilder.add(
"onServer",
InetAddress.getLocalHost().getHostName()
);
} catch (UnknownHostException ex) {
throw new UnexpectedErrorException(ex);
}
@ -134,9 +139,13 @@ public class ImportExport {
ccmFiles.createDirectory(String.format("exports/%s", exportName));
for (final String type : types) {
ccmFiles.createDirectory(String.format("exports/%s/%s",
ccmFiles.createDirectory(
String.format(
"exports/%s/%s",
exportName,
type));
type
)
);
typesArrayBuilder.add(type);
final List<Exportable> entitiesOfType = entities
@ -149,9 +158,13 @@ public class ImportExport {
manifestBuilder.add("types", typesArrayBuilder);
final OutputStream manifestOutputStream = ccmFiles
.createOutputStream(String.format("exports/%s/ccm-export.json",
exportName));
try (JsonWriter manifestWriter = Json.
.createOutputStream(
String.format(
"exports/%s/ccm-export.json",
exportName
)
);
try ( JsonWriter manifestWriter = Json.
createWriter(manifestOutputStream)) {
manifestWriter.writeObject(manifestBuilder.build());
@ -165,9 +178,11 @@ public class ImportExport {
for (final Map.Entry<String, List<Exportable>> entry
: typeEntityMap.entrySet()) {
createExportedEntities(exportName,
createExportedEntities(
exportName,
entry.getKey(),
entry.getValue());
entry.getValue()
);
}
}
@ -190,15 +205,15 @@ public class ImportExport {
try {
if (!ccmFiles.isDirectory(importsPath)) {
throw new IllegalArgumentException(String.format(
throw new IllegalArgumentException(
String.format(
"No imports with name \"%s\" available.",
importName));
importName)
);
}
} catch (FileAccessException
| FileDoesNotExistException
| InsufficientPermissionsException ex) {
throw new UnexpectedErrorException(ex);
}
@ -224,16 +239,21 @@ public class ImportExport {
importers
.stream()
.map(EntityImExporterTreeNode::getEntityImExporter)
.forEach(imExporter -> importEntitiesOfType(importName,
imExporter));
.forEach(
imExporter -> importEntitiesOfType(
importName,
imExporter
)
);
} catch (DependencyException ex) {
throw new UnexpectedErrorException(ex);
}
}
private boolean filterImporters(final ImportManifest manifest,
final EntityImExporterTreeNode node) {
private boolean filterImporters(
final ImportManifest manifest,
final EntityImExporterTreeNode node
) {
final AbstractEntityImExporter<?> imExporter = node
.getEntityImExporter();
final String type = imExporter.getEntityClass().getName();
@ -243,53 +263,60 @@ public class ImportExport {
private void importEntitiesOfType(
final String importName,
final AbstractEntityImExporter<?> entityImExporter) {
final AbstractEntityImExporter<?> entityImExporter
) {
final String type = entityImExporter.getEntityClass().getName();
try (final InputStream tocInputStream = ccmFiles
.createInputStream(String.format("imports/%s/%s/%s.json",
final String tocPath = String.format(
"imports/%s/%s/%s.json",
importName,
type,
type))) {
type
);
try (final InputStream tocInputStream = ccmFiles.createInputStream(
tocPath
)) {
final JsonReader tocReader = Json.createReader(tocInputStream);
final JsonObject toc = tocReader.readObject();
final JsonArray files = toc.getJsonArray("files");
files.forEach(value -> importEntity(importName,
files.forEach(
value -> importEntity(
importName,
type,
((JsonString) value).getString(),
entityImExporter));
entityImExporter
)
);
} catch (IOException
| FileDoesNotExistException
| FileAccessException
| InsufficientPermissionsException ex) {
throw new UnexpectedErrorException(ex);
}
}
private void importEntity(final String importName,
private void importEntity(
final String importName,
final String type,
final String fileName,
final AbstractEntityImExporter<?> imExporter) {
final String filePath = String.format("imports/%s/%s/%s",
final AbstractEntityImExporter<?> imExporter
) {
final String filePath = String.format(
"imports/%s/%s/%s",
importName,
type,
fileName);
try (final InputStream inputStream
= ccmFiles.createInputStream(filePath)) {
fileName
);
try (final InputStream inputStream = ccmFiles.createInputStream(
filePath
)) {
final String data = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8))
.lines()
.collect(Collectors.joining("\n"));
imExporter.importEntity(data);
} catch (IOException
| FileDoesNotExistException
| FileAccessException
@ -301,14 +328,12 @@ public class ImportExport {
}
public List<ImportManifest> listAvailableImportArchivies() {
final List<String> importArchivePaths;
try {
importArchivePaths = ccmFiles.listFiles("imports");
} catch (FileAccessException
| FileDoesNotExistException
| InsufficientPermissionsException ex) {
throw new UnexpectedErrorException(ex);
}
@ -337,14 +362,20 @@ public class ImportExport {
final AbstractEntityImExporter<?> imExporter;
if (instance.isUnsatisfied()) {
throw new UnexpectedErrorException(String.format(
throw new UnexpectedErrorException(
String.format(
"No EntityImExporter for entity type \"%s\" available.",
type));
type
)
);
} else if (instance.isAmbiguous()) {
throw new UnexpectedErrorException(String.format(
throw new UnexpectedErrorException(
String.format(
"Instance reference for EntityImExporter for entity "
+ "type \"%s\" is ambiguous.",
type));
type
)
);
} else {
imExporter = instance.get();
}
@ -354,11 +385,14 @@ public class ImportExport {
final String filename = String.format("%s.json", entity.getUuid());
final OutputStream outputStream;
try {
outputStream = ccmFiles.createOutputStream(String.format(
outputStream = ccmFiles.createOutputStream(
String.format(
"exports/%s/%s/%s",
exportName,
type,
filename));
filename
)
);
filesArrayBuilder.add(filename);
} catch (FileAccessException
| InsufficientPermissionsException ex) {
@ -372,10 +406,10 @@ public class ImportExport {
throw new UnexpectedErrorException(ex);
}
try (final OutputStreamWriter writer = new OutputStreamWriter(
outputStream, StandardCharsets.UTF_8)) {
outputStream,
StandardCharsets.UTF_8
)) {
writer.write(exportedEntity);
} catch (IOException ex) {
throw new UnexpectedErrorException(ex);
}
@ -385,15 +419,15 @@ public class ImportExport {
}
private boolean isImportArchive(final String path) {
final String manifestPath = String.format("imports/%s/ccm-export.json",
path);
final String manifestPath = String.format(
"imports/%s/ccm-export.json",
path
);
final boolean result;
try {
result = ccmFiles.existsFile(manifestPath);
} catch (FileAccessException | InsufficientPermissionsException ex) {
throw new UnexpectedErrorException(ex);
}
@ -401,7 +435,6 @@ public class ImportExport {
}
private ImportManifest createImportManifest(final String path) {
final String manifestPath = String.format(
"imports/%s/ccm-export.json", path
);
@ -465,7 +498,6 @@ public class ImportExport {
| FileAccessException
| FileDoesNotExistException
| InsufficientPermissionsException ex) {
throw new UnexpectedErrorException(ex);
}
}
@ -484,7 +516,6 @@ public class ImportExport {
@Override
public Class<? extends Exportable> value() {
return value;
}

View File

@ -26,16 +26,21 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used to resolve {@link Group}s when importing or exporting them.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class GroupIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = 3700628942920771114L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -43,16 +48,18 @@ public class GroupIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final GroupRepository groupRepo = cdiUtil
.findBean(GroupRepository.class);
return groupRepo
return CdiUtil
.createCdiUtil()
.findBean(GroupRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Group with uuid %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Group with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
@ -64,4 +71,5 @@ public class GroupIdResolver implements Serializable, ObjectIdResolver {
public boolean canUseFor(final ObjectIdResolver objectIdResolver) {
return objectIdResolver instanceof GroupIdResolver;
}
}

View File

@ -26,17 +26,21 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used to resolve {@link Party} entities when import or exporting them.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
*/
@Deprecated
@RequestScoped
public class PartyIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -1208121020457080214L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -44,16 +48,18 @@ public class PartyIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PartyRepository partyRepository = cdiUtil
.findBean(PartyRepository.class);
return partyRepository
return CdiUtil
.createCdiUtil()
.findBean(PartyRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Party with uuid %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Party with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
@ -65,4 +71,5 @@ public class PartyIdResolver implements Serializable, ObjectIdResolver {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof PartyIdResolver;
}
}

View File

@ -27,17 +27,22 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used to resolve {@link Permission}s based on their UUID when importing or
* exporting them.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class PermissionIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -8397366681202009916L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -45,16 +50,18 @@ public class PermissionIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PermissionRepository permissionRepository = cdiUtil
.findBean(PermissionRepository.class);
return permissionRepository
return CdiUtil
.createCdiUtil()
.findBean(PermissionRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Permission with UUID %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Permission with UUID %s in the database.",
id.key.toString()
)
)
);
}
@Override
@ -66,4 +73,5 @@ public class PermissionIdResolver implements Serializable, ObjectIdResolver {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof PermissionIdResolver;
}
}

View File

@ -26,17 +26,21 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used to resolve {@link Role}s based on their UUIDs for import and export.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class RoleIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -1651704701257277011L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -44,15 +48,18 @@ public class RoleIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final RoleRepository roleRepository = cdiUtil
.findBean(RoleRepository.class);
return roleRepository
return CdiUtil
.createCdiUtil()
.findBean(RoleRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Role with uuid %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Role with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
@ -64,4 +71,5 @@ public class RoleIdResolver implements Serializable, ObjectIdResolver {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof RoleIdResolver;
}
}

View File

@ -26,18 +26,21 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used to resolve {@link User}s for import and export based on their UUIDs.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class UserIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = -2541656707906049331L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -45,16 +48,18 @@ public class UserIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final UserRepository userRepository = cdiUtil
.findBean(UserRepository.class);
return userRepository
return CdiUtil
.createCdiUtil()
.findBean(UserRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No User with name %s in the database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No User with name %s in the database.",
id.key.toString()
)
)
);
}
@Override
@ -66,4 +71,5 @@ public class UserIdResolver implements Serializable, ObjectIdResolver {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof UserIdResolver;
}
}

View File

@ -26,41 +26,48 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class ApplicationIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = 464933392877186401L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
public void bindItem(
final ObjectIdGenerator.IdKey idKey,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ApplicationRepository applicationRepository = cdiUtil
.findBean(ApplicationRepository.class);
return applicationRepository
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return CdiUtil
.createCdiUtil()
.findBean(ApplicationRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No ccmApplications with uuid %s in the " +
"database.", id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ccmApplications with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
public ObjectIdResolver newForDeserialization(final Object object) {
return new ApplicationIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver objectIdResolver) {
public boolean canUseFor(final ObjectIdResolver objectIdResolver) {
return objectIdResolver instanceof ApplicationIdResolver;
}
}

View File

@ -26,19 +26,23 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used to resolve {@link AssignableTask}s when import or exporting based on
* their UUIDs.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Deprecated
public class AssignableTaskIdResolver implements Serializable,
ObjectIdResolver {
private static final long serialVersionUID = -4634332219001315735L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -46,15 +50,18 @@ public class AssignableTaskIdResolver implements Serializable,
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final AssignableTaskRepository assignableTaskRepository = cdiUtil
.findBean(AssignableTaskRepository.class);
return assignableTaskRepository
return CdiUtil
.createCdiUtil()
.findBean(AssignableTaskRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No assignable tasks with uuid %s in the " + "database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No assignable tasks with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override

View File

@ -25,41 +25,49 @@ import org.libreccm.cdi.utils.CdiUtil;
import java.io.Serializable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 9/27/17
* Used to resolve {@link TaskComment}s based on their UUIDs when exporting or
* import them.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
public class TaskCommentIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = 1057961565308988397L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(ObjectIdGenerator.IdKey id,
Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id, final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final TaskCommentRepository taskCommentRepository = cdiUtil
.findBean(TaskCommentRepository.class);
return taskCommentRepository
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return CdiUtil
.createCdiUtil()
.findBean(TaskCommentRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No task comments with uuid %s in the " +
"database.", id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No task comments with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
public ObjectIdResolver newForDeserialization(Object context) {
public ObjectIdResolver newForDeserialization(final Object context) {
return new TaskCommentIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof TaskCommentIdResolver;
}
}

View File

@ -26,17 +26,21 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
* Used to resolve {@link Task}s based on the UUIDs for export or import.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class TaskIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = 6444989953192198987L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object object
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -44,15 +48,18 @@ public class TaskIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final TaskRepository taskRepository = cdiUtil
.findBean(TaskRepository.class);
return taskRepository
return CdiUtil
.createCdiUtil()
.findBean(TaskRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No tasks with uuid %s in the " +
"database.", id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No tasks with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override
@ -64,4 +71,5 @@ public class TaskIdResolver implements Serializable, ObjectIdResolver {
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof TaskIdResolver;
}
}

View File

@ -26,20 +26,21 @@ import javax.enterprise.context.RequestScoped;
import java.io.Serializable;
/**
*
* Used to resolve {@link Workflow}s based on their UUIDs for import or export.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created on 3/23/17
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Deprecated
@RequestScoped
public class WorkflowIdResolver implements Serializable, ObjectIdResolver {
private static final long serialVersionUID = 1951611806946125510L;
private static final long serialVersionUID = 1L;
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
public void bindItem(
final ObjectIdGenerator.IdKey id,
final Object pojo
) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
@ -48,15 +49,22 @@ public class WorkflowIdResolver implements Serializable, ObjectIdResolver {
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowRepository workflowRepository = cdiUtil
.findBean(WorkflowRepository.class);
final WorkflowRepository workflowRepository = cdiUtil.findBean(
WorkflowRepository.class
);
return workflowRepository
return CdiUtil
.createCdiUtil()
.findBean(WorkflowRepository.class)
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No workflows with uuid %s in the "
+ "database.",
id.key.toString())));
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No workflows with uuid %s in the database.",
id.key.toString()
)
)
);
}
@Override