Additional changes to handle subclasses

This commit is contained in:
Cyrus 2022-08-05 08:34:58 -04:00
parent d80af7bc9e
commit 4e70141df0
7 changed files with 15 additions and 6 deletions

View File

@ -12,4 +12,6 @@ import java.util.UUID;
@Repository
public interface PolicyRepository<T extends Policy> extends JpaRepository<T, UUID> {
T save(T policy);
T updatePolicy(T policy, UUID uuid);
}

View File

@ -16,4 +16,10 @@ public interface ReferenceDigestValueRepository extends JpaRepository<ReferenceD
List<ReferenceDigestValue> findValuesByBaseRimId(UUID uuid);
List<ReferenceDigestValue> findValuesBySupportRimId(UUID uuid);
/**
* List<String> results = session.createCriteria(User.class).add(Projections.projectionList().add(Projections.property("id")).add()....).list();
*
* List<Object[]> result = session.createCriteria(User.class).setProjection(Projections.projectionList().add(Projections.groupProperty("lastName")).add(Projections.rowCount())).list();
*/
}

View File

@ -10,5 +10,7 @@ import java.util.UUID;
* Setting up for new creation for CRUD operations.
*/
@Repository
public interface ReferenceManifestRepository extends JpaRepository<ReferenceManifest, UUID> {
public interface ReferenceManifestRepository<T extends ReferenceManifest>
extends JpaRepository<ReferenceManifest, UUID> {
T saveRIM(T rim);
}

View File

@ -113,7 +113,7 @@ public class PolicyServiceImpl extends DbServiceImpl<Policy> implements DefaultS
dbPolicy = policy;
} else {
// will not return null, throws and exception
dbPolicy = policyRepository.getReferenceById(uuid);
dbPolicy = (Policy) policyRepository.getReferenceById(uuid);
// run through things that aren't equal and update
}

View File

@ -50,7 +50,7 @@ public class ReferenceManifestServiceImpl extends DbServiceImpl<ReferenceManifes
@Override
public ReferenceManifest doWithRetry(final RetryContext context)
throws DBManagerException {
return referenceManifestRepository.save(rim);
return referenceManifestRepository.saveRIM(rim);
}
});
}

View File

@ -6,7 +6,6 @@ import hirs.attestationca.portal.model.PolicyPageModel;
import hirs.attestationca.portal.page.PageController;
import hirs.attestationca.portal.page.PageMessages;
import hirs.attestationca.portal.page.params.NoPageParams;
import hirs.data.persist.policy.Policy;
import hirs.data.persist.policy.SupplyChainPolicy;
import hirs.persist.PolicyManagerException;
import hirs.persist.service.AppraiserService;
@ -963,7 +962,7 @@ public class PolicyPageController extends PageController<NoPageParams> {
final PageMessages messages, final String successMessage,
final SupplyChainPolicy policy) {
// save the policy to the DB
policyService.updatePolicy(policy);
policyService.updatePolicy(policy, policy.getId());
// Log and set the success message
messages.addSuccess(successMessage);

View File

@ -219,7 +219,7 @@ public abstract class ReferenceManifestSelector<T extends ReferenceManifest> {
// construct and execute query
private Set<T> execute() {
Set<T> results = this.referenceManifestService.get(this);
Set<T> results = this.referenceManifestService.get;
return results;
}