Adding new columns on Annotation entity
This commit is contained in:
parent
fa97c55862
commit
9d706c6e11
|
@ -0,0 +1,30 @@
|
|||
package gr.cite.annotation.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import gr.cite.annotation.data.conventers.DatabaseEnum;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public enum AnnotationProtectionType implements DatabaseEnum<Short> {
|
||||
|
||||
Private((short) 0),
|
||||
EntityAccessors((short) 1);
|
||||
|
||||
private final Short value;
|
||||
|
||||
AnnotationProtectionType(Short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public Short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private static final Map<Short, AnnotationProtectionType> map = EnumUtils.getEnumValueMap(AnnotationProtectionType.class);
|
||||
|
||||
public static AnnotationProtectionType of(Short i) {
|
||||
return map.get(i);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package gr.cite.annotation.data;
|
||||
|
||||
import gr.cite.annotation.common.enums.AnnotationProtectionType;
|
||||
import gr.cite.annotation.common.enums.IsActive;
|
||||
import gr.cite.annotation.data.conventers.AnnotationProtectionTypeConverter;
|
||||
import gr.cite.annotation.data.conventers.IsActiveConverter;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
|
@ -18,7 +20,7 @@ public class AnnotationEntity {
|
|||
public static final String _id = "id";
|
||||
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", nullable = false)
|
||||
@Column(name = "entity_id", columnDefinition = "uuid", nullable = false)
|
||||
private UUID entityId;
|
||||
|
||||
public static final String _entityId = "entityId";
|
||||
|
@ -33,12 +35,37 @@ public class AnnotationEntity {
|
|||
|
||||
public static final String _anchor = "anchor";
|
||||
|
||||
@Id
|
||||
@Column(name = "payload", nullable = false)
|
||||
private String payload;
|
||||
|
||||
public static final String _payload = "payload";
|
||||
|
||||
@Column(name = "subject_id", columnDefinition = "uuid", nullable = false)
|
||||
private UUID subjectId;
|
||||
|
||||
public static final String _subjectId = "subjectId";
|
||||
|
||||
@Column(name = "thread_id", columnDefinition = "uuid", nullable = false)
|
||||
private UUID threadId;
|
||||
|
||||
public static final String _threadId = "threadId";
|
||||
|
||||
@Column(name = "parent_id", columnDefinition = "uuid")
|
||||
private UUID parentId;
|
||||
|
||||
public static final String _parentId = "parentId";
|
||||
|
||||
@Column(name = "protection_type", nullable = false)
|
||||
@Convert(converter = AnnotationProtectionTypeConverter.class)
|
||||
private AnnotationProtectionType protectionType;
|
||||
|
||||
public static final String _protectionType = "protectionType";
|
||||
|
||||
@Column(name = "time_stamp", nullable = false)
|
||||
private Instant timeStamp;
|
||||
|
||||
public static final String _timeStamp = "timeStamp";
|
||||
|
||||
@Column(name = "\"created_at\"", nullable = false)
|
||||
private Instant createdAt;
|
||||
|
||||
|
@ -95,6 +122,46 @@ public class AnnotationEntity {
|
|||
this.payload = payload;
|
||||
}
|
||||
|
||||
public UUID getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(UUID subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public UUID getThreadId() {
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public void setThreadId(UUID threadId) {
|
||||
this.threadId = threadId;
|
||||
}
|
||||
|
||||
public UUID getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(UUID parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Instant getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(Instant timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public AnnotationProtectionType getProtectionType() {
|
||||
return protectionType;
|
||||
}
|
||||
|
||||
public void setProtectionType(AnnotationProtectionType protectionType) {
|
||||
this.protectionType = protectionType;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package gr.cite.annotation.data.conventers;
|
||||
|
||||
import gr.cite.annotation.common.enums.AnnotationProtectionType;
|
||||
import jakarta.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class AnnotationProtectionTypeConverter extends DatabaseEnumConverter<AnnotationProtectionType, Short>{
|
||||
@Override
|
||||
protected AnnotationProtectionType of(Short i) {
|
||||
return AnnotationProtectionType.of(i);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
package gr.cite.annotation.model;
|
||||
|
||||
import gr.cite.annotation.common.enums.AnnotationProtectionType;
|
||||
import gr.cite.annotation.common.enums.IsActive;
|
||||
import gr.cite.annotation.data.conventers.AnnotationProtectionTypeConverter;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Convert;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
@ -27,6 +31,26 @@ public class Annotation {
|
|||
|
||||
public static final String _payload = "payload";
|
||||
|
||||
private UUID subjectId;
|
||||
|
||||
public static final String _subjectId = "subjectId";
|
||||
|
||||
private UUID threadId;
|
||||
|
||||
public static final String _threadId = "threadId";
|
||||
|
||||
private UUID parentId;
|
||||
|
||||
public static final String _parentId = "parentId";
|
||||
|
||||
private AnnotationProtectionType protectionType;
|
||||
|
||||
public static final String _protectionType = "protectionType";
|
||||
|
||||
private Instant timeStamp;
|
||||
|
||||
public static final String _timeStamp = "timeStamp";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
@ -79,6 +103,46 @@ public class Annotation {
|
|||
this.payload = payload;
|
||||
}
|
||||
|
||||
public UUID getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(UUID subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public UUID getThreadId() {
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public void setThreadId(UUID threadId) {
|
||||
this.threadId = threadId;
|
||||
}
|
||||
|
||||
public UUID getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(UUID parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public AnnotationProtectionType getProtectionType() {
|
||||
return protectionType;
|
||||
}
|
||||
|
||||
public void setProtectionType(AnnotationProtectionType protectionType) {
|
||||
this.protectionType = protectionType;
|
||||
}
|
||||
|
||||
public Instant getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(Instant timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,16 @@ public class AnnotationBuilder extends BaseBuilder<Annotation, AnnotationEntity>
|
|||
m.setAnchor(d.getAnchor());
|
||||
if (fields.hasField(this.asIndexer(Annotation._payload)))
|
||||
m.setPayload(d.getPayload());
|
||||
if (fields.hasField(this.asIndexer(Annotation._subjectId)))
|
||||
m.setSubjectId(d.getSubjectId());
|
||||
if (fields.hasField(this.asIndexer(Annotation._threadId)))
|
||||
m.setThreadId(d.getThreadId());
|
||||
if (fields.hasField(this.asIndexer(Annotation._parentId)))
|
||||
m.setParentId(d.getParentId());
|
||||
if (fields.hasField(this.asIndexer(Annotation._protectionType)))
|
||||
m.setProtectionType(d.getProtectionType());
|
||||
if (fields.hasField(this.asIndexer(Annotation._timeStamp)))
|
||||
m.setTimeStamp(d.getTimeStamp());
|
||||
if (fields.hasField(this.asIndexer(Annotation._createdAt)))
|
||||
m.setCreatedAt(d.getCreatedAt());
|
||||
if (fields.hasField(this.asIndexer(Annotation._updatedAt)))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package gr.cite.annotation.query;
|
||||
|
||||
import gr.cite.annotation.authorization.AuthorizationFlags;
|
||||
import gr.cite.annotation.common.enums.AnnotationProtectionType;
|
||||
import gr.cite.annotation.common.enums.IsActive;
|
||||
import gr.cite.annotation.common.scope.user.UserScope;
|
||||
import gr.cite.annotation.data.AnnotationEntity;
|
||||
|
@ -37,6 +38,8 @@ public class AnnotationQuery extends QueryBase<AnnotationEntity> {
|
|||
|
||||
private Collection<String> anchors;
|
||||
|
||||
private Collection<UUID> threadIds;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
private final UserScope userScope;
|
||||
|
@ -143,6 +146,21 @@ public class AnnotationQuery extends QueryBase<AnnotationEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public AnnotationQuery threadIds(UUID value) {
|
||||
this.threadIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AnnotationQuery threadIds(UUID... value) {
|
||||
this.threadIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AnnotationQuery threadIds(Collection<UUID> values) {
|
||||
this.threadIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || this.isEmpty(this.entityIds);
|
||||
|
@ -199,6 +217,12 @@ public class AnnotationQuery extends QueryBase<AnnotationEntity> {
|
|||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.threadIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(AnnotationEntity._threadId));
|
||||
for (UUID item : this.threadIds)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
|
@ -220,6 +244,16 @@ public class AnnotationQuery extends QueryBase<AnnotationEntity> {
|
|||
return AnnotationEntity._anchor;
|
||||
else if (item.match(Annotation._payload))
|
||||
return AnnotationEntity._payload;
|
||||
else if (item.match(Annotation._subjectId))
|
||||
return AnnotationEntity._subjectId;
|
||||
else if (item.match(Annotation._threadId))
|
||||
return AnnotationEntity._threadId;
|
||||
else if (item.match(Annotation._parentId))
|
||||
return AnnotationEntity._parentId;
|
||||
else if (item.match(Annotation._protectionType))
|
||||
return AnnotationEntity._protectionType;
|
||||
else if (item.match(Annotation._timeStamp))
|
||||
return AnnotationEntity._timeStamp;
|
||||
else if (item.match(Annotation._createdAt))
|
||||
return AnnotationEntity._createdAt;
|
||||
else if (item.match(Annotation._updatedAt))
|
||||
|
@ -239,6 +273,11 @@ public class AnnotationQuery extends QueryBase<AnnotationEntity> {
|
|||
item.setEntityType(QueryBase.convertSafe(tuple, columns, AnnotationEntity._entityType, String.class));
|
||||
item.setAnchor(QueryBase.convertSafe(tuple, columns, AnnotationEntity._anchor, String.class));
|
||||
item.setPayload(QueryBase.convertSafe(tuple, columns, AnnotationEntity._payload, String.class));
|
||||
item.setSubjectId(QueryBase.convertSafe(tuple, columns, AnnotationEntity._subjectId, UUID.class));
|
||||
item.setThreadId(QueryBase.convertSafe(tuple, columns, AnnotationEntity._threadId, UUID.class));
|
||||
item.setParentId(QueryBase.convertSafe(tuple, columns, AnnotationEntity._parentId, UUID.class));
|
||||
item.setProtectionType(QueryBase.convertSafe(tuple, columns, AnnotationEntity._protectionType, AnnotationProtectionType.class));
|
||||
item.setTimeStamp(QueryBase.convertSafe(tuple, columns, AnnotationEntity._timeStamp, Instant.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, AnnotationEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, AnnotationEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, AnnotationEntity._isActive, IsActive.class));
|
||||
|
|
|
@ -24,6 +24,8 @@ public class AnnotationLookup extends Lookup {
|
|||
|
||||
private List<String> anchors;
|
||||
|
||||
private List<UUID> threadIds;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
@ -80,6 +82,14 @@ public class AnnotationLookup extends Lookup {
|
|||
this.anchors = anchors;
|
||||
}
|
||||
|
||||
public List<UUID> getThreadIds() {
|
||||
return threadIds;
|
||||
}
|
||||
|
||||
public void setThreadIds(List<UUID> threadIds) {
|
||||
this.threadIds = threadIds;
|
||||
}
|
||||
|
||||
public AnnotationQuery enrich(QueryFactory queryFactory) {
|
||||
AnnotationQuery query = queryFactory.query(AnnotationQuery.class);
|
||||
if (this.like != null)
|
||||
|
@ -96,6 +106,8 @@ public class AnnotationLookup extends Lookup {
|
|||
query.entityTypes(this.entityTypes);
|
||||
if (this.anchors != null)
|
||||
query.anchors(this.anchors);
|
||||
if (this.threadIds != null)
|
||||
query.threadIds(this.threadIds);
|
||||
|
||||
this.enrichCommon(query);
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@ export class AnnotationLookup extends Lookup implements AnnotationFilter {
|
|||
like: string;
|
||||
ids: Guid[];
|
||||
excludedIds: Guid[];
|
||||
isActive: IsActive;
|
||||
isActive: IsActive[];
|
||||
entityIds: Guid[];
|
||||
entityTypes: string[];
|
||||
anchors: string[];
|
||||
groupIds: Guid[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -22,8 +23,9 @@ export interface AnnotationFilter {
|
|||
like: string;
|
||||
ids: Guid[];
|
||||
excludedIds: Guid[];
|
||||
isActive: IsActive;
|
||||
isActive: IsActive[];
|
||||
entityIds: Guid[];
|
||||
entityTypes: string[];
|
||||
anchors: string[];
|
||||
groupIds: Guid[];
|
||||
}
|
|
@ -10,7 +10,7 @@ import { catchError } from "rxjs/operators";
|
|||
|
||||
@Injectable()
|
||||
export class AnnotationService {
|
||||
private get apiBase(): string { return `${this.installationConfiguration.annotationServiceAddress}/annotation`; }
|
||||
private get apiBase(): string { return `${this.installationConfiguration.annotationServiceAddress}annotation`; }
|
||||
|
||||
constructor(
|
||||
private installationConfiguration: ConfigurationService,
|
||||
|
|
|
@ -27,6 +27,7 @@ export abstract class BaseInterceptor implements HttpInterceptor {
|
|||
|
||||
return (req.params instanceof BaseHttpParams && req.params.interceptorContext && Array.isArray(req.params.interceptorContext.interceptAllRequests) && req.params.interceptorContext.interceptAllRequests.includes(this.type))
|
||||
|| req.url.startsWith(this.configurationService.server)
|
||||
|| req.url.startsWith(this.configurationService.notificationServiceAddress);
|
||||
|| req.url.startsWith(this.configurationService.notificationServiceAddress)
|
||||
|| req.url.startsWith(this.configurationService.annotationServiceAddress);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue