Skip to content

Commit

Permalink
Rework PR-> use @FieldNameConstants to identify fieldnames
Browse files Browse the repository at this point in the history
  • Loading branch information
tunacicek committed Aug 23, 2023
1 parent 29f3c06 commit 78174dc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.FieldNameConstants;

@Entity
@Getter
@Setter
Expand All @@ -40,6 +42,7 @@
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
@FieldNameConstants
public class Shell {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.FieldNameConstants;

@Entity
@Getter
Expand All @@ -36,6 +37,7 @@
@AllArgsConstructor
@With
@JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@FieldNameConstants
public class ShellIdentifier {
public static final String GLOBAL_ASSET_ID_KEY = "globalAssetId";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.FieldNameConstants;

@Entity
@Getter
Expand All @@ -33,6 +34,7 @@
@NoArgsConstructor
@AllArgsConstructor
@With
@FieldNameConstants
public class ShellIdentifierExternalSubjectReference {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.FieldNameConstants;

@Entity
@Getter
Expand All @@ -31,6 +32,7 @@
@NoArgsConstructor
@AllArgsConstructor
@With
@FieldNameConstants
public class ShellIdentifierExternalSubjectReferenceKey {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ private Predicate applyFilter( Root<T> root, CriteriaQuery<?> cq, CriteriaBuilde

private Predicate getAllShellsPredicate( Root<T> root, CriteriaQuery<?> cq, CriteriaBuilder criteriaBuilder, Instant searchValue ) {
// Join Shell -> ShellIdentifier
Join<Shell,ShellIdentifier > shellIdentifierShellJoin = root.join( "identifiers" );
String t = Shell.Fields.identifiers;
Join<Shell,ShellIdentifier > shellIdentifierShellJoin = root.join( Shell.Fields.identifiers );
// join ShellIdentifier -> ShellIdentifierExternalSubjectReference -> ShellIdentifierExternalSubjectReferenceKey
Join<ShellIdentifierExternalSubjectReference,ShellIdentifierExternalSubjectReferenceKey> referenceKeyJoin = shellIdentifierShellJoin.join( "externalSubjectId" ).join( "keys" );
Join<ShellIdentifierExternalSubjectReference,ShellIdentifierExternalSubjectReferenceKey> referenceKeyJoin = shellIdentifierShellJoin.join( ShellIdentifier.Fields.externalSubjectId ).join( ShellIdentifierExternalSubjectReference.Fields.keys );

return criteriaBuilder.and(
criteriaBuilder.or(
criteriaBuilder.equal( referenceKeyJoin.get( "value" ), tenantId ),
criteriaBuilder.equal( referenceKeyJoin.get( ShellIdentifierExternalSubjectReferenceKey.Fields.value ), tenantId ),
criteriaBuilder.and(
criteriaBuilder.equal( referenceKeyJoin.get( "value" ), publicWildcardPrefix ),
criteriaBuilder.in( shellIdentifierShellJoin.get( "key" ) ).value( publicWildcardAllowedTypes )
criteriaBuilder.equal( referenceKeyJoin.get( ShellIdentifierExternalSubjectReferenceKey.Fields.value ), publicWildcardPrefix ),
criteriaBuilder.in( shellIdentifierShellJoin.get( ShellIdentifier.Fields.key ) ).value( publicWildcardAllowedTypes )
)
),
criteriaBuilder.greaterThan( root.get( sortFieldName ), searchValue )
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ spring:

registry:
external-subject-id-wildcard-prefix: PUBLIC_READABLE
external-subject-id-wildcard-allowed-types:
external-subject-id-wildcard-allowed-types: manufacturerPartId,assetLifecyclePhase
idm:
owningTenantId: TENANT_ONE

0 comments on commit 78174dc

Please sign in to comment.