diff options
author | Liam Fallon <liam.fallon@est.tech> | 2022-12-20 09:55:45 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-12-20 09:55:45 +0000 |
commit | e70bf5c909a4d5abcbc7adcbb4aa120c2e045660 (patch) | |
tree | 2622919eb5c86d6400cab8ff35795bd8c75cd730 /models/src/main | |
parent | ba5988ab370f3dc5e5214823046e897d25aba0bf (diff) | |
parent | e18a523f4fc8075dc5022871fa96ca8754c2c979 (diff) |
Merge "Refactor instanceId as primary key in JpaAutomationComposition"
Diffstat (limited to 'models/src/main')
7 files changed, 110 insertions, 179 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java index 28a558cc1..f9cc880d0 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java @@ -20,19 +20,21 @@ package org.onap.policy.clamp.models.acm.persistence.concepts; +import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.UUID; import javax.persistence.CascadeType; import javax.persistence.Column; -import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.ForeignKey; +import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; -import javax.persistence.ManyToMany; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; @@ -44,12 +46,9 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.base.validation.annotations.VerifyKey; +import org.onap.policy.models.base.Validated; /** * Class to represent a automation composition in the database. @@ -61,17 +60,20 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @EqualsAndHashCode(callSuper = false) -public class JpaAutomationComposition extends PfConcept implements PfAuthorative<AutomationComposition> { - private static final long serialVersionUID = -4725410933242154805L; +public class JpaAutomationComposition extends Validated + implements PfAuthorative<AutomationComposition>, Comparable<JpaAutomationComposition> { - @Column + @Id @NotNull private String instanceId; - @EmbeddedId - @VerifyKey @NotNull - private PfConceptKey key; + @Column + private String name; + + @NotNull + @Column + private String version; @Column @NotNull @@ -91,17 +93,17 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative @Column(columnDefinition = "TINYINT DEFAULT 1") private Boolean primed; - @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @NotNull - private Map<@NotNull UUID, @NotNull @Valid JpaAutomationCompositionElement> elements; - // @formatter:on + @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @JoinColumn(name = "instanceId", foreignKey = @ForeignKey(name = "ac_element_fk")) + private List<@NotNull @Valid JpaAutomationCompositionElement> elements; /** * The Default Constructor creates a {@link JpaAutomationComposition} object with a null key. */ public JpaAutomationComposition() { this(UUID.randomUUID().toString(), new PfConceptKey(), UUID.randomUUID().toString(), - AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>()); + AutomationCompositionState.UNINITIALISED, new ArrayList<>()); } /** @@ -115,9 +117,10 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative */ public JpaAutomationComposition(@NonNull final String instanceId, @NonNull final PfConceptKey key, @NonNull final String compositionId, @NonNull final AutomationCompositionState state, - @NonNull final Map<UUID, JpaAutomationCompositionElement> elements) { + @NonNull final List<JpaAutomationCompositionElement> elements) { this.instanceId = instanceId; - this.key = key; + this.name = key.getName(); + this.version = key.getVersion(); this.compositionId = compositionId; this.state = state; this.elements = elements; @@ -129,15 +132,14 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative * @param copyConcept the concept to copy from */ public JpaAutomationComposition(@NonNull final JpaAutomationComposition copyConcept) { - super(copyConcept); this.instanceId = copyConcept.instanceId; - this.key = new PfConceptKey(copyConcept.key); + this.name = copyConcept.name; + this.version = copyConcept.version; this.compositionId = copyConcept.compositionId; this.state = copyConcept.state; this.orderedState = copyConcept.orderedState; this.description = copyConcept.description; - this.elements = - PfUtils.mapMap(copyConcept.elements, JpaAutomationCompositionElement::new, new LinkedHashMap<>(0)); + this.elements = PfUtils.mapList(copyConcept.elements, JpaAutomationCompositionElement::new); this.primed = copyConcept.primed; } @@ -155,15 +157,17 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative var automationComposition = new AutomationComposition(); automationComposition.setInstanceId(UUID.fromString(instanceId)); - automationComposition.setName(getKey().getName()); - automationComposition.setVersion(getKey().getVersion()); + automationComposition.setName(name); + automationComposition.setVersion(version); automationComposition.setCompositionId(UUID.fromString(compositionId)); automationComposition.setState(state); automationComposition.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); automationComposition.setDescription(description); - automationComposition.setElements( - PfUtils.mapMap(elements, JpaAutomationCompositionElement::toAuthorative, new LinkedHashMap<>(0))); automationComposition.setPrimed(primed); + automationComposition.setElements(new LinkedHashMap<>(this.elements.size())); + for (var element : this.elements) { + automationComposition.getElements().put(UUID.fromString(element.getElementId()), element.toAuthorative()); + } return automationComposition; } @@ -171,66 +175,43 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative @Override public void fromAuthorative(@NonNull final AutomationComposition automationComposition) { this.instanceId = automationComposition.getInstanceId().toString(); - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfConceptKey(automationComposition.getName(), automationComposition.getVersion())); - } - + this.name = automationComposition.getName(); + this.version = automationComposition.getVersion(); this.compositionId = automationComposition.getCompositionId().toString(); this.state = automationComposition.getState(); this.orderedState = automationComposition.getOrderedState(); this.description = automationComposition.getDescription(); this.primed = automationComposition.getPrimed(); - this.elements = new LinkedHashMap<>(automationComposition.getElements().size()); + this.elements = new ArrayList<>(automationComposition.getElements().size()); for (var elementEntry : automationComposition.getElements().entrySet()) { - var jpaAutomationCompositionElement = new JpaAutomationCompositionElement(); - jpaAutomationCompositionElement - .setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString())); + var jpaAutomationCompositionElement = + new JpaAutomationCompositionElement(elementEntry.getKey().toString(), this.instanceId); jpaAutomationCompositionElement.fromAuthorative(elementEntry.getValue()); - this.elements.put(elementEntry.getKey(), jpaAutomationCompositionElement); - } - } - - @Override - public List<PfKey> getKeys() { - var keyList = getKey().getKeys(); - - for (var element : elements.values()) { - keyList.addAll(element.getKeys()); - } - - return keyList; - } - - @Override - public void clean() { - key.clean(); - description = (description == null ? null : description.trim()); - - for (var element : elements.values()) { - element.clean(); + this.elements.add(jpaAutomationCompositionElement); } } @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { + public int compareTo(final JpaAutomationComposition other) { + if (other == null) { return -1; } - if (this == otherConcept) { + if (this == other) { return 0; } - if (getClass() != otherConcept.getClass()) { - return this.getClass().getName().compareTo(otherConcept.getClass().getName()); - } - final var other = (JpaAutomationComposition) otherConcept; var result = ObjectUtils.compare(instanceId, other.instanceId); if (result != 0) { return result; } - result = key.compareTo(other.key); + result = ObjectUtils.compare(name, other.name); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(version, other.version); if (result != 0) { return result; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java index d8e4237b7..79576f6eb 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java @@ -23,15 +23,14 @@ package org.onap.policy.clamp.models.acm.persistence.concepts; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.UUID; import java.util.function.UnaryOperator; import javax.persistence.AttributeOverride; import javax.persistence.Column; import javax.persistence.Convert; -import javax.persistence.EmbeddedId; import javax.persistence.Entity; +import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.Lob; @@ -46,11 +45,9 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.base.Validated; import org.onap.policy.models.base.validation.annotations.VerifyKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -64,13 +61,16 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @EqualsAndHashCode(callSuper = false) -public class JpaAutomationCompositionElement extends PfConcept implements PfAuthorative<AutomationCompositionElement> { - private static final long serialVersionUID = -1791732273187890213L; +public class JpaAutomationCompositionElement extends Validated + implements PfAuthorative<AutomationCompositionElement>, Comparable<JpaAutomationCompositionElement> { - @EmbeddedId - @VerifyKey + @Id @NotNull - private PfReferenceKey key; + private String elementId; + + @Column + @NotNull + private String instanceId; // @formatter:off @VerifyKey @@ -112,29 +112,33 @@ public class JpaAutomationCompositionElement extends PfConcept implements PfAuth * The Default Constructor creates a {@link JpaAutomationCompositionElement} object with a null key. */ public JpaAutomationCompositionElement() { - this(new PfReferenceKey()); + this(UUID.randomUUID().toString(), UUID.randomUUID().toString()); } /** * The Key Constructor creates a {@link JpaAutomationCompositionElement} object with the given concept key. * - * @param key the key + * @param elementId The id of the automation composition instance Element + * @param instanceId The id of the automation composition instance */ - public JpaAutomationCompositionElement(@NonNull final PfReferenceKey key) { - this(key, new PfConceptKey(), new PfConceptKey(), AutomationCompositionState.UNINITIALISED); + public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId) { + this(elementId, instanceId, new PfConceptKey(), new PfConceptKey(), AutomationCompositionState.UNINITIALISED); } /** * The Key Constructor creates a {@link JpaAutomationCompositionElement} object with all mandatory fields. * - * @param key the key + * @param elementId The id of the automation composition instance Element + * @param instanceId The id of the automation composition instance * @param definition the TOSCA definition of the automation composition element * @param participantType the TOSCA definition of the participant running the automation composition element * @param state the state of the automation composition */ - public JpaAutomationCompositionElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition, - @NonNull final PfConceptKey participantType, @NonNull final AutomationCompositionState state) { - this.key = key; + public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId, + @NonNull final PfConceptKey definition, @NonNull final PfConceptKey participantType, + @NonNull final AutomationCompositionState state) { + this.elementId = elementId; + this.instanceId = instanceId; this.definition = definition; this.participantType = participantType; this.state = state; @@ -146,8 +150,8 @@ public class JpaAutomationCompositionElement extends PfConcept implements PfAuth * @param copyConcept the concept to copy from */ public JpaAutomationCompositionElement(@NonNull final JpaAutomationCompositionElement copyConcept) { - super(copyConcept); - this.key = new PfReferenceKey(copyConcept.key); + this.elementId = copyConcept.elementId; + this.instanceId = copyConcept.instanceId; this.definition = new PfConceptKey(copyConcept.definition); this.participantType = new PfConceptKey(copyConcept.participantType); this.participantId = new PfConceptKey(copyConcept.participantId); @@ -170,7 +174,7 @@ public class JpaAutomationCompositionElement extends PfConcept implements PfAuth public AutomationCompositionElement toAuthorative() { var element = new AutomationCompositionElement(); - element.setId(UUID.fromString(getKey().getLocalName())); + element.setId(UUID.fromString(elementId)); element.setDefinition(new ToscaConceptIdentifier(definition)); element.setParticipantType(new ToscaConceptIdentifier(participantType)); element.setParticipantId(new ToscaConceptIdentifier(participantId)); @@ -184,11 +188,6 @@ public class JpaAutomationCompositionElement extends PfConcept implements PfAuth @Override public void fromAuthorative(@NonNull final AutomationCompositionElement element) { - if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfReferenceKey()); - getKey().setLocalName(element.getId().toString()); - } - this.definition = element.getDefinition().asConceptKey(); this.participantType = element.getParticipantType().asConceptKey(); this.participantId = element.getParticipantId().asConceptKey(); @@ -199,42 +198,20 @@ public class JpaAutomationCompositionElement extends PfConcept implements PfAuth } @Override - public List<PfKey> getKeys() { - List<PfKey> keyList = getKey().getKeys(); - - keyList.add(definition); - keyList.add(participantType); - keyList.add(participantId); - - return keyList; - } - - @Override - public void clean() { - key.clean(); - definition.clean(); - participantType.clean(); - participantId.clean(); - - if (description != null) { - description = description.trim(); - } - } - - @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { + public int compareTo(final JpaAutomationCompositionElement other) { + if (other == null) { return -1; } - if (this == otherConcept) { + if (this == other) { return 0; } - if (getClass() != otherConcept.getClass()) { - return this.getClass().getName().compareTo(otherConcept.getClass().getName()); + + var result = ObjectUtils.compare(elementId, other.elementId); + if (result != 0) { + return result; } - final JpaAutomationCompositionElement other = (JpaAutomationCompositionElement) otherConcept; - int result = key.compareTo(other.key); + result = ObjectUtils.compare(instanceId, other.instanceId); if (result != 0) { return result; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java index 8c39f6e2b..21efc66d3 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java @@ -25,7 +25,6 @@ package org.onap.policy.clamp.models.acm.persistence.provider; import java.util.List; import java.util.Optional; import java.util.UUID; -import javax.persistence.EntityNotFoundException; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import lombok.AllArgsConstructor; @@ -33,9 +32,9 @@ import lombok.NonNull; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; -import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -57,7 +56,7 @@ public class AutomationCompositionProvider { */ @Transactional(readOnly = true) public AutomationComposition getAutomationComposition(final UUID instanceId) { - var result = automationCompositionRepository.findByInstanceId(instanceId.toString()); + var result = automationCompositionRepository.findById(instanceId.toString()); if (result.isEmpty()) { throw new PfModelRuntimeException(Status.NOT_FOUND, "AutomationComposition not found"); } @@ -65,21 +64,6 @@ public class AutomationCompositionProvider { } /** - * Get automation composition. - * - * @param automationCompositionId the ID of the automation composition to get - * @return the automation composition found - */ - @Transactional(readOnly = true) - public AutomationComposition getAutomationComposition(final ToscaConceptIdentifier automationCompositionId) { - try { - return automationCompositionRepository.getById(automationCompositionId.asConceptKey()).toAuthorative(); - } catch (EntityNotFoundException e) { - throw new PfModelRuntimeException(Status.NOT_FOUND, "AutomationComposition not found", e); - } - } - - /** * Find automation composition. * * @param instanceId the ID of the automation composition to get @@ -87,7 +71,7 @@ public class AutomationCompositionProvider { */ @Transactional(readOnly = true) public Optional<AutomationComposition> findAutomationComposition(final UUID instanceId) { - var result = automationCompositionRepository.findByInstanceId(instanceId.toString()); + var result = automationCompositionRepository.findById(instanceId.toString()); return result.stream().map(JpaAutomationComposition::toAuthorative).findFirst(); } @@ -100,11 +84,9 @@ public class AutomationCompositionProvider { @Transactional(readOnly = true) public Optional<AutomationComposition> findAutomationComposition( final ToscaConceptIdentifier automationCompositionId) { - return findAutomationComposition(automationCompositionId.asConceptKey()); - } - - private Optional<AutomationComposition> findAutomationComposition(@NonNull final PfConceptKey key) { - return automationCompositionRepository.findById(key).map(JpaAutomationComposition::toAuthorative); + return automationCompositionRepository + .findOne(createExample(null, automationCompositionId.getName(), automationCompositionId.getVersion())) + .map(JpaAutomationComposition::toAuthorative); } /** @@ -156,10 +138,24 @@ public class AutomationCompositionProvider { * @return the automation compositions found */ @Transactional(readOnly = true) - public List<AutomationComposition> getAutomationCompositions(final String name, final String version) { + public List<AutomationComposition> getAutomationCompositions(final UUID compositionId, final String name, + final String version) { + + return ProviderUtils + .asEntityList(automationCompositionRepository.findAll(createExample(compositionId, name, version))); + } - return ProviderUtils.asEntityList( - automationCompositionRepository.getFiltered(JpaAutomationComposition.class, name, version)); + private Example<JpaAutomationComposition> createExample(final UUID compositionId, final String name, + final String version) { + var example = new JpaAutomationComposition(); + example.setCompositionId(compositionId != null ? compositionId.toString() : null); + example.setName(name); + example.setVersion(version); + example.setInstanceId(null); + example.setElements(null); + example.setState(null); + + return Example.of(example); } /** @@ -169,14 +165,14 @@ public class AutomationCompositionProvider { * @return the automation composition deleted */ public AutomationComposition deleteAutomationComposition(@NonNull final UUID instanceId) { - var jpaDeleteAutomationComposition = automationCompositionRepository.findByInstanceId(instanceId.toString()); + var jpaDeleteAutomationComposition = automationCompositionRepository.findById(instanceId.toString()); if (jpaDeleteAutomationComposition.isEmpty()) { var errorMessage = "delete of automation composition \"" + instanceId + "\" failed, automation composition does not exist"; throw new PfModelRuntimeException(Response.Status.NOT_FOUND, errorMessage); } - automationCompositionRepository.deleteById(jpaDeleteAutomationComposition.get().getKey()); + automationCompositionRepository.deleteById(instanceId.toString()); return jpaDeleteAutomationComposition.get().toAuthorative(); } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java index 9dc07ae72..871aa8902 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfAuthorative; -import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.base.Validated; @@ -44,7 +43,7 @@ public final class ProviderUtils { * @param conceptDescription the description used for validation result * @return the list of Jpa objects */ - public static <A, J extends PfConcept & PfAuthorative<A>> List<J> getJpaAndValidateList( + public static <A, J extends Validated & PfAuthorative<A>> List<J> getJpaAndValidateList( List<A> authorativeConceptList, Supplier<J> jpaSupplier, String conceptDescription) { var validationResult = new BeanValidationResult(conceptDescription + " List", authorativeConceptList); diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java index aba752667..bb8b3e6d9 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java @@ -21,17 +21,14 @@ package org.onap.policy.clamp.models.acm.persistence.repository; import java.util.List; -import java.util.Optional; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; -import org.onap.policy.models.base.PfConceptKey; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.QueryByExampleExecutor; import org.springframework.stereotype.Repository; @Repository public interface AutomationCompositionRepository - extends JpaRepository<JpaAutomationComposition, PfConceptKey>, FilterRepository { - - Optional<JpaAutomationComposition> findByInstanceId(String instanceId); + extends JpaRepository<JpaAutomationComposition, String>, QueryByExampleExecutor<JpaAutomationComposition> { List<JpaAutomationComposition> findByCompositionId(String compositionId); } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java index cdedc5eb5..fb4c0bc48 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ package org.onap.policy.clamp.models.acm.persistence.repository; import java.util.List; import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.dao.PfFilterParametersIntfc; public interface FilterRepository { @@ -33,18 +32,6 @@ public interface FilterRepository { * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts * of type T are returned, if name is not null and version is null, all versions of that concept matching the * name are returned. - * @param filterParams filter parameters - * @return the objects that was retrieved from the database - */ - <T extends PfConcept> List<T> getFiltered(Class<T> someClass, PfFilterParametersIntfc filterParams); - - /** - * Get an object from the database, referred to by concept key. - * - * @param <T> the type of the object to get, a subclass of {@link PfConcept} - * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts - * of type T are returned, if name is not null and version is null, all versions of that concept matching the - * name are returned. * @param name the name of the object to get, null returns all objects * @param version the version the object to get, null returns all objects for a specified name * @return the objects that was retrieved from the database diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java index d7e81d4da..470f05379 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.dao.PfDao; -import org.onap.policy.models.dao.PfFilterParametersIntfc; import org.onap.policy.models.dao.impl.ProxyDao; import org.springframework.stereotype.Repository; @@ -40,11 +39,6 @@ public class FilterRepositoryImpl implements FilterRepository { } @Override - public <T extends PfConcept> List<T> getFiltered(Class<T> someClass, PfFilterParametersIntfc filterParams) { - return getPfDao().getFiltered(someClass, filterParams); - } - - @Override public <T extends PfConcept> List<T> getFiltered(Class<T> someClass, String name, String version) { return getPfDao().getFiltered(someClass, name, version); } |