Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • simonrose/naming-backend
  • anderslindh1/naming-backend
  • andersharrisson/naming-backend
3 results
Show changes
Showing
with 2411 additions and 171 deletions
/*
* Copyright (C) 2021 European Spallation Source ERIC.
* Copyright (C) 2024 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -18,12 +18,16 @@
package org.openepics.names.repository.model;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a name.
*
......@@ -31,62 +35,116 @@ import javax.persistence.Table;
*/
@Entity
@Table(name = "name")
public class Name extends NameStructure implements Serializable {
public class Name extends NameStructure {
public static final String FIELD_SYSTEM_GROUP_ID = "systemgroupId";
public static final String FIELD_SYSTEM_ID = "systemId";
public static final String FIELD_SUBSYSTEM_ID = "subsystemId";
public static final String FIELD_DEVICETYPE_ID = "devicetypeId";
public static final String FIELD_INSTANCE_INDEX = "instanceIndex";
public static final String FIELD_CONVENTION_NAME = "conventionName";
public static final String FIELD_CONVENTION_NAME_EQUIVALENCE = "conventionNameEquivalence";
@Column(name = "systemgroup_id")
private Long systemGroupId;
@Column(name = "system_id")
private Long systemId;
@Column(name = "subsystem_id")
private Long subsystemId;
@Column(name = "devicetype_id")
private Long deviceTypeId;
@Column(name = "instance_index")
private String instanceIndex;
@Column(name = "convention_name")
private String conventionName;
@Column(name = "convention_name_equivalence")
private String conventionNameEquivalence;
/**
*
* Constructor for name.
*/
private static final long serialVersionUID = 7313392211143183879L;
private String systemgroup_uuid;
private String system_uuid;
private String subsystem_uuid;
private String devicetype_uuid;
private String instance_index;
private String convention_name;
private String convention_name_equivalence;
public UUID getSystemgroupUuid() {
return systemgroup_uuid != null ? UUID.fromString(systemgroup_uuid) : null;
}
public void setSystemgroupUuid(UUID systemgroup_uuid) {
this.systemgroup_uuid = systemgroup_uuid != null ? systemgroup_uuid.toString() : null;
}
public UUID getSystemUuid() {
return system_uuid != null ? UUID.fromString(system_uuid) : null;
}
public void setSystemUuid(UUID system_uuid) {
this.system_uuid = system_uuid != null ? system_uuid.toString() : null;
}
public UUID getSubsystemUuid() {
return subsystem_uuid != null ? UUID.fromString(subsystem_uuid) : null;
public Name() {
}
public void setSubsystemUuid(UUID subsystem_uuid) {
this.subsystem_uuid = subsystem_uuid != null ? subsystem_uuid.toString() : null;
}
public UUID getDevicetypeUuid() {
return devicetype_uuid != null ? UUID.fromString(devicetype_uuid) : null;
}
public void setDevicetypeUuid(UUID devicetype_uuid) {
this.devicetype_uuid = devicetype_uuid != null ? devicetype_uuid.toString() : null;
/**
* Constructor for name.
*
* @param uuid uuid
* @param systemGroupId system group id
* @param systemId system id
* @param subsystemId subsystem id
* @param deviceTypeId device type id
* @param index index
* @param conventionName convention name
* @param conventionNameEquivalence convention name equivalence
* @param description description
* @param status status
* @param deleted deleted
* @param requested requested
* @param requestedBy requested by
* @param requestedComment requested comment
*/
public Name(UUID uuid, Long systemGroupId, Long systemId, Long subsystemId, Long deviceTypeId,
String index, String conventionName, String conventionNameEquivalence, String description,
Status status, Boolean deleted,
Date requested, String requestedBy, String requestedComment) {
setUuid(uuid);
setSystemGroupId(systemGroupId);
setSystemId(systemId);
setSubsystemId(subsystemId);
setDeviceTypeId(deviceTypeId);
setInstanceIndex(index);
setConventionName(conventionName);
setConventionNameEquivalence(conventionNameEquivalence);
setDescription(description);
setStatus(status);
setDeleted(deleted);
setRequested(requested);
setRequestedBy(requestedBy);
setRequestedComment(requestedComment);
}
public Long getSystemGroupId() {
return systemGroupId;
}
public void setSystemGroupId(Long systemGroupId) {
this.systemGroupId = systemGroupId;
}
public Long getSystemId() {
return systemId;
}
public void setSystemId(Long systemId) {
this.systemId = systemId;
}
public Long getSubsystemId() {
return subsystemId;
}
public void setSubsystemId(Long subsystemId) {
this.subsystemId = subsystemId;
}
public Long getDeviceTypeId() {
return deviceTypeId;
}
public void setDeviceTypeId(Long deviceTypeId) {
this.deviceTypeId = deviceTypeId;
}
public String getInstanceIndex() {
return instance_index;
return instanceIndex;
}
public void setInstanceIndex(String instance_index) {
this.instance_index = instance_index;
public void setInstanceIndex(String instanceIndex) {
this.instanceIndex = instanceIndex;
}
public String getConventionName() {
return convention_name;
return conventionName;
}
public void setConventionName(String convention_name) {
this.convention_name = convention_name;
public void setConventionName(String conventionName) {
this.conventionName = conventionName;
}
public String getConventionNameEquivalence() {
return convention_name_equivalence;
return conventionNameEquivalence;
}
public void setConventionNameEquivalence(String convention_name_equivalence) {
this.convention_name_equivalence = convention_name_equivalence;
public void setConventionNameEquivalence(String conventionNameEquivalence) {
this.conventionNameEquivalence = conventionNameEquivalence;
}
@Override
......@@ -109,25 +167,25 @@ public class Name extends NameStructure implements Serializable {
return false;
}
if (getSystemgroupUuid() == null) {
if (other.getSystemgroupUuid() != null)
if (getSystemGroupId() == null) {
if (other.getSystemGroupId() != null)
return false;
} else if (!getSystemgroupUuid().equals(other.getSystemgroupUuid()))
} else if (!getSystemGroupId().equals(other.getSystemGroupId()))
return false;
if (getSystemUuid() == null) {
if (other.getSystemUuid() != null)
if (getSystemId() == null) {
if (other.getSystemId() != null)
return false;
} else if (!getSystemUuid().equals(other.getSystemUuid()))
} else if (!getSystemId().equals(other.getSystemId()))
return false;
if (getSubsystemUuid() == null) {
if (other.getSubsystemUuid() != null)
if (getSubsystemId() == null) {
if (other.getSubsystemId() != null)
return false;
} else if (!getSubsystemUuid().equals(other.getSubsystemUuid()))
} else if (!getSubsystemId().equals(other.getSubsystemId()))
return false;
if (getDevicetypeUuid() == null) {
if (other.getDevicetypeUuid() != null)
if (getDeviceTypeId() == null) {
if (other.getDeviceTypeId() != null)
return false;
} else if (!getDevicetypeUuid().equals(other.getDevicetypeUuid()))
} else if (!getDeviceTypeId().equals(other.getDeviceTypeId()))
return false;
if (getInstanceIndex() == null) {
if (other.getInstanceIndex() != null)
......@@ -148,8 +206,9 @@ public class Name extends NameStructure implements Serializable {
return true;
}
public boolean equalsId(Object other) {
return other instanceof Name && ((Name) other).getId().equals(getId());
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
......@@ -159,16 +218,15 @@ public class Name extends NameStructure implements Serializable {
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"systemgroup_uuid\": " + getSystemgroupUuid());
sb.append(", \"system_uuid\": " + getSystemUuid());
sb.append(", \"subsystem_uuid\": " + getSubsystemUuid());
sb.append(", \"devicetype_uuid\": " + getDevicetypeUuid());
sb.append(", \"systemgroup_id\": " + getSystemGroupId());
sb.append(", \"system_id\": " + getSystemId());
sb.append(", \"subsystem_id\": " + getSubsystemId());
sb.append(", \"devicetype_id\": " + getDeviceTypeId());
sb.append(", \"instance_index\": " + getInstanceIndex());
sb.append(", \"convention_name\": " + getConventionName());
sb.append(", \"convention_name_equivalence\": " + getConventionNameEquivalence());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
......@@ -187,7 +245,6 @@ public class Name extends NameStructure implements Serializable {
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"convention_name\": " + getConventionName());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
......
/*
* Copyright (C) 2021 European Spallation Source ERIC.
* Copyright (C) 2024 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -18,11 +18,11 @@
package org.openepics.names.repository.model;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.MappedSuperclass;
......@@ -36,25 +36,38 @@ import org.openepics.names.rest.beans.Status;
* @author Lars Johansson
*/
@MappedSuperclass
public class NameStructure extends Persistable implements Serializable {
/**
*
*/
private static final long serialVersionUID = 736094142259082938L;
public class NameStructure extends Persistable {
public static final String FIELD_UUID = "uuid";
public static final String FIELD_DESCRIPTION = "description";
public static final String FIELD_STATUS = "status";
public static final String FIELD_DELETED = "deleted";
public static final String FIELD_REQUESTED = "requested";
public static final String FIELD_REQUESTED_BY = "requestedBy";
public static final String FIELD_REQUESTED_COMMENT = "requestedComment";
public static final String FIELD_PROCESSED = "processed";
public static final String FIELD_PROCESSED_BY = "processedBy";
public static final String FIELD_PROCESSED_COMMENT = "processedComment";
public static final String FUNCTION_GET_MNEMONIC_PATH_DEVICE_STRUCTURE = "get_mnemonic_path_device_structure";
public static final String FUNCTION_GET_MNEMONIC_PATH_SYSTEM_STRUCTURE = "get_mnemonic_path_system_structure";
public static final String FUNCTION_GET_INSTANCE_INDEX = "get_instance_index";
private String uuid;
private String description;
@Enumerated(EnumType.STRING)
private Status status;
private Boolean latest;
private Boolean deleted;
private Date requested;
private String requested_by;
private String requested_comment;
@Column(name = "requested_by")
private String requestedBy;
@Column(name = "requested_comment")
private String requestedComment;
private Date processed;
private String processed_by;
private String processed_comment;
@Column(name = "processed_by")
private String processedBy;
@Column(name = "processed_comment")
private String processedComment;
public UUID getUuid() {
return uuid != null ? UUID.fromString(uuid) : null;
......@@ -74,12 +87,6 @@ public class NameStructure extends Persistable implements Serializable {
public void setStatus(Status status) {
this.status = status;
}
public Boolean isLatest() {
return latest;
}
public void setLatest(Boolean latest) {
this.latest = latest;
}
public Boolean isDeleted() {
return deleted;
}
......@@ -93,16 +100,16 @@ public class NameStructure extends Persistable implements Serializable {
this.requested = requested;
}
public String getRequestedBy() {
return requested_by;
return requestedBy;
}
public void setRequestedBy(String requested_by) {
this.requested_by = requested_by;
public void setRequestedBy(String requestedBy) {
this.requestedBy = requestedBy;
}
public String getRequestedComment() {
return requested_comment;
return requestedComment;
}
public void setRequestedComment(String requested_comment) {
this.requested_comment = requested_comment;
public void setRequestedComment(String requestedComment) {
this.requestedComment = requestedComment;
}
public Date getProcessed() {
return processed;
......@@ -111,16 +118,42 @@ public class NameStructure extends Persistable implements Serializable {
this.processed = processed;
}
public String getProcessedBy() {
return processed_by;
return processedBy;
}
public void setProcessedBy(String processed_by) {
this.processed_by = processed_by;
public void setProcessedBy(String processedBy) {
this.processedBy = processedBy;
}
public String getProcessedComment() {
return processed_comment;
return processedComment;
}
public void setProcessedComment(String processedComment) {
this.processedComment = processedComment;
}
/**
* Utility method to help set attributes for structure class, which in practice is either of its sub classes.
*
* @param requested requested
* @param requestedBy requested by
* @param requestedComment requested comment
*/
public void setAttributesRequested(Date requested, String requestedBy, String requestedComment) {
setRequested(requested);
setRequestedBy(requestedBy);
setRequestedComment(requestedComment);
}
public void setProcessedComment(String processed_comment) {
this.processed_comment = processed_comment;
/**
* Utility method to help set attributes for structure class, which in practice is either of its sub classes.
*
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public void setAttributesProcessed(Date processed, String processedBy, String processedComment) {
setProcessed(processed);
setProcessedBy(processedBy);
setProcessedComment(processedComment);
}
@Override
......@@ -158,11 +191,6 @@ public class NameStructure extends Persistable implements Serializable {
return false;
} else if (!getStatus().equals(other.getStatus()))
return false;
if (isLatest() == null) {
if (other.isLatest() != null)
return false;
} else if (!isLatest().equals(other.isLatest()))
return false;
if (isDeleted() == null) {
if (other.isDeleted() != null)
return false;
......@@ -202,13 +230,9 @@ public class NameStructure extends Persistable implements Serializable {
return true;
}
public boolean equalsId(Object other) {
return other instanceof NameStructure && ((NameStructure) other).getId().equals(getId());
}
@Override
public int hashCode() {
return Objects.hash(getUuid());
return Objects.hash(getId(), getUuid());
}
}
......@@ -20,7 +20,7 @@ package org.openepics.names.repository.model;
import javax.annotation.Nullable;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A superclass implementing the properties required by JPA. It that should be extended by all classes that need to be
......@@ -29,9 +29,10 @@ import java.io.Serializable;
* @author Marko Kolar
*/
@MappedSuperclass
public class Persistable implements Serializable {
public class Persistable {
private static final long serialVersionUID = 8393161299438204843L;
public static final String FIELD_ID = "id";
public static final String FIELD_VERSION = "version";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
......@@ -82,4 +83,9 @@ public class Persistable implements Serializable {
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId());
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
* Copyright (C) 2024 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -18,10 +18,15 @@
package org.openepics.names.repository.model;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import org.openepics.names.rest.beans.Status;
/**
* A superclass implementing properties required by JPA. It should be extended by
* System structure and Device structure classes that need to be persisted to the database.
......@@ -29,23 +34,53 @@ import javax.persistence.MappedSuperclass;
* @author Lars Johansson
*/
@MappedSuperclass
public class Structure extends NameStructure implements Serializable {
public class Structure extends NameStructure {
/**
*
*/
private static final long serialVersionUID = -5980090194197159918L;
public static final String FIELD_MNEMONIC = "mnemonic";
public static final String FIELD_MNEMONIC_EQUIVALENCE = "mnemonicEquivalence";
public static final String FIELD_ORDERING = "ordering";
private String name;
private String mnemonic;
private String mnemonic_equivalence;
@Column(name = "mnemonic_equivalence")
private String mnemonicEquivalence;
private Integer ordering;
public String getName() {
return name;
/**
* Constructor for structure.
*/
public Structure() {
}
public void setName(String name) {
this.name = name;
/**
* Constructor for structure.
*
* @param uuid uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public Structure(UUID uuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean deleted,
Date processed, String processedBy, String processedComment) {
setUuid(uuid);
setMnemonic(mnemonic);
setMnemonicEquivalence(mnemonicEquivalence);
setOrdering(ordering);
setDescription(description);
setStatus(status);
setDeleted(deleted);
setProcessed(processed);
setProcessedBy(processedBy);
setProcessedComment(processedComment);
}
public String getMnemonic() {
return mnemonic;
}
......@@ -53,10 +88,16 @@ public class Structure extends NameStructure implements Serializable {
this.mnemonic = mnemonic;
}
public String getMnemonicEquivalence() {
return mnemonic_equivalence;
return mnemonicEquivalence;
}
public void setMnemonicEquivalence(String mnemonicEquivalence) {
this.mnemonicEquivalence = mnemonicEquivalence;
}
public void setMnemonicEquivalence(String mnemonic_equivalence) {
this.mnemonic_equivalence = mnemonic_equivalence;
public Integer getOrdering() {
return ordering;
}
public void setOrdering(Integer ordering) {
this.ordering = ordering;
}
@Override
......@@ -79,11 +120,6 @@ public class Structure extends NameStructure implements Serializable {
return false;
}
if (getName() == null) {
if (other.getName() != null)
return false;
} else if (!getName().equals(other.getName()))
return false;
if (getMnemonic() == null) {
if (other.getMnemonic() != null)
return false;
......@@ -94,12 +130,53 @@ public class Structure extends NameStructure implements Serializable {
return false;
} else if (!getMnemonicEquivalence().equals(other.getMnemonicEquivalence()))
return false;
if (getOrdering() == null) {
if (other.getOrdering() != null)
return false;
} else if (!getOrdering().equals(other.getOrdering()))
return false;
return true;
}
public boolean equalsId(Object other) {
return other instanceof Structure && ((Structure) other).getId().equals(getId());
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
* Copyright (C) 2024 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -18,11 +18,16 @@
package org.openepics.names.repository.model;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a subsystem name part.
*
......@@ -32,18 +37,64 @@ import javax.persistence.Table;
@Table(name = "subsystem")
public class Subsystem extends Structure {
public static final String FIELD_PARENT_ID = "parentId";
public static final String FUNCTION_GET_PARENT_UUID_SUBSYSTEM = "get_parent_uuid_subsystem";
public static final String FUNCTION_GET_MNEMONIC_PATH_SUBSYSTEM = "get_mnemonic_path_subsystem";
@Column(name = "parent_id")
private Long parentId;
/**
* Constructor for subsystem.
*/
public Subsystem() {
}
/**
* Constructor for subsystem.
*
* @param uuid uuid
* @param parentId parent id
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
private static final long serialVersionUID = 5662135540008222500L;
public Subsystem(UUID uuid, Long parentId,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid, mnemonic, mnemonicEquivalence, ordering,
description, status, deleted,
processed, processedBy, processedComment);
setParentId(parentId);
}
private String parent_uuid;
/**
* Constructor for subsystem.
*
* @param auditStructure audit structure
*/
public Subsystem(AuditStructure auditStructure) {
super(auditStructure.getUuid(),
auditStructure.getMnemonic(), auditStructure.getMnemonicEquivalence(), auditStructure.getOrdering(), auditStructure.getDescription(),
auditStructure.getStatus(), auditStructure.isDeleted(),
auditStructure.getProcessed(), auditStructure.getProcessedBy(), auditStructure.getProcessedComment());
setParentId(auditStructure.getParentId());
this.id = auditStructure.getId();
}
public UUID getParentUuid() {
return parent_uuid != null ? UUID.fromString(parent_uuid) : null;
public Long getParentId() {
return parentId;
}
public void setParentUuid(UUID parent_uuid) {
this.parent_uuid = parent_uuid != null ? parent_uuid.toString() : null;
public void setParentId(Long parentId) {
this.parentId = parentId;
}
@Override
......@@ -66,17 +117,18 @@ public class Subsystem extends Structure {
return false;
}
if (getParentUuid() == null) {
if (other.getParentUuid() != null)
if (getParentId() == null) {
if (other.getParentId() != null)
return false;
} else if (!getParentUuid().equals(other.getParentUuid()))
} else if (!getParentId().equals(other.getParentId()))
return false;
return true;
}
public boolean equalsId(Object other) {
return other instanceof Subsystem && ((Subsystem) other).getId().equals(getId());
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
......@@ -86,13 +138,12 @@ public class Subsystem extends Structure {
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"parent_uuid\": " + getParentUuid());
sb.append(", \"name\": " + getName());
sb.append(", \"parent_id\": " + getParentId());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
......@@ -104,6 +155,7 @@ public class Subsystem extends Structure {
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
......@@ -111,7 +163,6 @@ public class Subsystem extends Structure {
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
......
/*
* Copyright (C) 2021 European Spallation Source ERIC.
* Copyright (C) 2024 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -18,11 +18,16 @@
package org.openepics.names.repository.model;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a system name part.
*
......@@ -32,18 +37,65 @@ import javax.persistence.Table;
@Table(name = "system")
public class System extends Structure {
public static final String FIELD_PARENT_ID = "parentId";
public static final String FUNCTION_GET_PARENT_UUID_SYSTEM = "get_parent_uuid_system";
public static final String FUNCTION_GET_MNEMONIC_PATH_SYSTEM = "get_mnemonic_path_system";
@Column(name = "parent_id")
private Long parentId;
/**
* Constructor for system.
*/
public System() {
}
/**
* Constructor for system.
*
* @param uuid uuid
* @param parentId parent id
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
private static final long serialVersionUID = -4323438470765348486L;
public System(UUID uuid, Long parentId,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid,
mnemonic, mnemonicEquivalence, ordering, description,
status, deleted,
processed, processedBy, processedComment);
setParentId(parentId);
}
private String parent_uuid;
/**
* Constructor for system.
*
* @param auditStructure audit structure
*/
public System(AuditStructure auditStructure) {
super(auditStructure.getUuid(),
auditStructure.getMnemonic(), auditStructure.getMnemonicEquivalence(), auditStructure.getOrdering(), auditStructure.getDescription(),
auditStructure.getStatus(), auditStructure.isDeleted(),
auditStructure.getProcessed(), auditStructure.getProcessedBy(), auditStructure.getProcessedComment());
setParentId(auditStructure.getParentId());
this.id = auditStructure.getId();
}
public UUID getParentUuid() {
return parent_uuid != null ? UUID.fromString(parent_uuid) : null;
public Long getParentId() {
return parentId;
}
public void setParentUuid(UUID parent_uuid) {
this.parent_uuid = parent_uuid != null ? parent_uuid.toString() : null;
public void setParentId(Long parentId) {
this.parentId = parentId;
}
@Override
......@@ -66,17 +118,18 @@ public class System extends Structure {
return false;
}
if (getParentUuid() == null) {
if (other.getParentUuid() != null)
if (getParentId() == null) {
if (other.getParentId() != null)
return false;
} else if (!getParentUuid().equals(other.getParentUuid()))
} else if (!getParentId().equals(other.getParentId()))
return false;
return true;
}
public boolean equalsId(Object other) {
return other instanceof System && ((System) other).getId().equals(getId());
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
......@@ -86,13 +139,12 @@ public class System extends Structure {
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"parent_uuid\": " + getParentUuid());
sb.append(", \"name\": " + getName());
sb.append(", \"parent_id\": " + getParentId());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
......@@ -104,6 +156,7 @@ public class System extends Structure {
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
......@@ -111,7 +164,6 @@ public class System extends Structure {
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
......
/*
* Copyright (C) 2021 European Spallation Source ERIC.
* Copyright (C) 2024 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -18,9 +18,15 @@
package org.openepics.names.repository.model;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a system group name part.
*
......@@ -31,9 +37,47 @@ import javax.persistence.Table;
public class SystemGroup extends Structure {
/**
* Constructor for system group.
*/
public SystemGroup() {
}
/**
* Constructor for system group.
*
* @param uuid uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public SystemGroup(UUID uuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid,
mnemonic, mnemonicEquivalence, ordering, description,
status, deleted,
processed, processedBy, processedComment);
}
/**
* Constructor for system group.
*
* @param auditStructure audit structure
*/
private static final long serialVersionUID = 6298835206366539021L;
public SystemGroup(AuditStructure auditStructure) {
super(auditStructure.getUuid(),
auditStructure.getMnemonic(), auditStructure.getMnemonicEquivalence(), auditStructure.getOrdering(), auditStructure.getDescription(),
auditStructure.getStatus(), auditStructure.isDeleted(),
auditStructure.getProcessed(), auditStructure.getProcessedBy(), auditStructure.getProcessedComment());
this.id = auditStructure.getId();
}
@Override
public boolean equals(Object obj) {
......@@ -58,8 +102,9 @@ public class SystemGroup extends Structure {
return true;
}
public boolean equalsId(Object other) {
return other instanceof SystemGroup && ((SystemGroup) other).getId().equals(getId());
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
......@@ -69,12 +114,11 @@ public class SystemGroup extends Structure {
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"name\": " + getName());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
......@@ -86,6 +130,7 @@ public class SystemGroup extends Structure {
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
......@@ -93,7 +138,6 @@ public class SystemGroup extends Structure {
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
......
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a device group name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "wip_devicegroup")
public class WipDeviceGroup extends WipStructure {
public static final String FIELD_PARENT_UUID = "parentUuid";
public static final String FUNCTION_GET_MNEMONIC_PATH_DEVICEGROUP = "wip_get_mnemonic_path_devicegroup";
@Column(name = "parent_uuid")
private String parentUuid;
/**
* Constructor for DeviceGroup.
*/
public WipDeviceGroup() {
}
/**
* Constructor for DeviceGroup.
*
* @param uuid uuid
* @param parentUuid parent uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public WipDeviceGroup(UUID uuid, UUID parentUuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean latest, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid, mnemonic, mnemonicEquivalence, ordering,
description, status, latest, deleted,
processed, processedBy, processedComment);
setParentUuid(parentUuid);
}
public UUID getParentUuid() {
return parentUuid != null ? UUID.fromString(parentUuid) : null;
}
public void setParentUuid(UUID parentUuid) {
this.parentUuid = parentUuid != null ? parentUuid.toString() : null;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((WipDeviceGroup) obj);
}
public boolean equals(WipDeviceGroup other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
if (getParentUuid() == null) {
if (other.getParentUuid() != null)
return false;
} else if (!getParentUuid().equals(other.getParentUuid()))
return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"parent_uuid\": " + getParentUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a device type name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "wip_devicetype")
public class WipDeviceType extends WipStructure {
public static final String FIELD_PARENT_UUID = "parentUuid";
public static final String FUNCTION_GET_MNEMONIC_PATH_DEVICETYPE = "wip_get_mnemonic_path_devicetype";
@Column(name = "parent_uuid")
private String parentUuid;
/**
* Constructor for DeviceType.
*/
public WipDeviceType() {
}
/**
* Constructor for DeviceType.
*
* @param uuid uuid
* @param parentUuid parent uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public WipDeviceType(UUID uuid, UUID parentUuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean latest, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid, mnemonic, mnemonicEquivalence, ordering,
description, status, latest, deleted,
processed, processedBy, processedComment);
setParentUuid(parentUuid);
}
public UUID getParentUuid() {
return parentUuid != null ? UUID.fromString(parentUuid) : null;
}
public void setParentUuid(UUID parentUuid) {
this.parentUuid = parentUuid != null ? parentUuid.toString() : null;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((WipDeviceType) obj);
}
public boolean equals(WipDeviceType other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
if (getParentUuid() == null) {
if (other.getParentUuid() != null)
return false;
} else if (!getParentUuid().equals(other.getParentUuid()))
return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"parent_uuid\": " + getParentUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a discipline name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "wip_discipline")
public class WipDiscipline extends WipStructure {
/**
* Constructor for Discipline.
*/
public WipDiscipline() {
}
/**
* Constructor for Discipline.
*
* @param uuid uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public WipDiscipline(UUID uuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean latest, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid, mnemonic, mnemonicEquivalence, ordering,
description, status, latest, deleted,
processed, processedBy, processedComment);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((WipDiscipline) obj);
}
public boolean equals(WipDiscipline other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a name.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "wip_name")
public class WipName extends WipNameStructure {
public static final String FIELD_SYSTEM_GROUP_UUID = "systemgroupUuid";
public static final String FIELD_SYSTEM_UUID = "systemUuid";
public static final String FIELD_SUBSYSTEM_UUID = "subsystemUuid";
public static final String FIELD_DEVICETYPE_UUID = "devicetypeUuid";
public static final String FIELD_INSTANCE_INDEX = "instanceIndex";
public static final String FIELD_CONVENTION_NAME = "conventionName";
public static final String FIELD_CONVENTION_NAME_EQUIVALENCE = "conventionNameEquivalence";
@Column(name = "systemgroup_uuid")
private String systemGroupUuid;
@Column(name = "system_uuid")
private String systemUuid;
@Column(name = "subsystem_uuid")
private String subsystemUuid;
@Column(name = "devicetype_uuid")
private String deviceTypeUuid;
@Column(name = "instance_index")
private String instanceIndex;
@Column(name = "convention_name")
private String conventionName;
@Column(name = "convention_name_equivalence")
private String conventionNameEquivalence;
/**
* Constructor for Name.
*/
public WipName() {
}
/**
* Constructor for Name.
*
* @param uuid uuid
* @param systemGroupUuid system group uuid
* @param systemUuid system uuid
* @param subsystemUuid subsystem uuid
* @param deviceTypeUuid device type uuid
* @param index index
* @param conventionName convention name
* @param conventionNameEquivalence convention name equivalence
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param requested requested
* @param requestedBy requested by
* @param requestedComment requested comment
*/
public WipName(UUID uuid, UUID systemGroupUuid, UUID systemUuid, UUID subsystemUuid, UUID deviceTypeUuid,
String index, String conventionName, String conventionNameEquivalence, String description,
Status status, Boolean latest, Boolean deleted,
Date requested, String requestedBy, String requestedComment) {
setUuid(uuid);
setSystemGroupUuid(systemGroupUuid);
setSystemUuid(systemUuid);
setSubsystemUuid(subsystemUuid);
setDeviceTypeUuid(deviceTypeUuid);
setInstanceIndex(index);
setConventionName(conventionName);
setConventionNameEquivalence(conventionNameEquivalence);
setDescription(description);
setStatus(status);
setLatest(latest);
setDeleted(deleted);
setRequested(requested);
setRequestedBy(requestedBy);
setRequestedComment(requestedComment);
}
public UUID getSystemGroupUuid() {
return systemGroupUuid != null ? UUID.fromString(systemGroupUuid) : null;
}
public void setSystemGroupUuid(UUID systemGroupUuid) {
this.systemGroupUuid = systemGroupUuid != null ? systemGroupUuid.toString() : null;
}
public UUID getSystemUuid() {
return systemUuid != null ? UUID.fromString(systemUuid) : null;
}
public void setSystemUuid(UUID systemUuid) {
this.systemUuid = systemUuid != null ? systemUuid.toString() : null;
}
public UUID getSubsystemUuid() {
return subsystemUuid != null ? UUID.fromString(subsystemUuid) : null;
}
public void setSubsystemUuid(UUID subsystemUuid) {
this.subsystemUuid = subsystemUuid != null ? subsystemUuid.toString() : null;
}
public UUID getDeviceTypeUuid() {
return deviceTypeUuid != null ? UUID.fromString(deviceTypeUuid) : null;
}
public void setDeviceTypeUuid(UUID deviceTypeUuid) {
this.deviceTypeUuid = deviceTypeUuid != null ? deviceTypeUuid.toString() : null;
}
public String getInstanceIndex() {
return instanceIndex;
}
public void setInstanceIndex(String instanceIndex) {
this.instanceIndex = instanceIndex;
}
public String getConventionName() {
return conventionName;
}
public void setConventionName(String conventionName) {
this.conventionName = conventionName;
}
public String getConventionNameEquivalence() {
return conventionNameEquivalence;
}
public void setConventionNameEquivalence(String conventionNameEquivalence) {
this.conventionNameEquivalence = conventionNameEquivalence;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((WipName) obj);
}
public boolean equals(WipName other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
if (getSystemGroupUuid() == null) {
if (other.getSystemGroupUuid() != null)
return false;
} else if (!getSystemGroupUuid().equals(other.getSystemGroupUuid()))
return false;
if (getSystemUuid() == null) {
if (other.getSystemUuid() != null)
return false;
} else if (!getSystemUuid().equals(other.getSystemUuid()))
return false;
if (getSubsystemUuid() == null) {
if (other.getSubsystemUuid() != null)
return false;
} else if (!getSubsystemUuid().equals(other.getSubsystemUuid()))
return false;
if (getDeviceTypeUuid() == null) {
if (other.getDeviceTypeUuid() != null)
return false;
} else if (!getDeviceTypeUuid().equals(other.getDeviceTypeUuid()))
return false;
if (getInstanceIndex() == null) {
if (other.getInstanceIndex() != null)
return false;
} else if (!getInstanceIndex().equals(other.getInstanceIndex()))
return false;
if (getConventionName() == null) {
if (other.getConventionName() != null)
return false;
} else if (!getConventionName().equals(other.getConventionName()))
return false;
if (getConventionNameEquivalence() == null) {
if (other.getConventionNameEquivalence() != null)
return false;
} else if (!getConventionNameEquivalence().equals(other.getConventionNameEquivalence()))
return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"systemgroup_uuid\": " + getSystemGroupUuid());
sb.append(", \"system_uuid\": " + getSystemUuid());
sb.append(", \"subsystem_uuid\": " + getSubsystemUuid());
sb.append(", \"devicetype_uuid\": " + getDeviceTypeUuid());
sb.append(", \"instance_index\": " + getInstanceIndex());
sb.append(", \"convention_name\": " + getConventionName());
sb.append(", \"convention_name_equivalence\": " + getConventionNameEquivalence());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"convention_name\": " + getConventionName());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.MappedSuperclass;
import org.openepics.names.repository.model.Persistable;
import org.openepics.names.rest.beans.Status;
/**
* A superclass implementing properties required by JPA. It should be extended by
* name and structure classes that need to be persisted to the database.
*
* @author Lars Johansson
*/
@MappedSuperclass
public class WipNameStructure extends Persistable {
public static final String FIELD_UUID = "uuid";
public static final String FIELD_DESCRIPTION = "description";
public static final String FIELD_STATUS = "status";
public static final String FIELD_LATEST = "latest";
public static final String FIELD_DELETED = "deleted";
public static final String FIELD_REQUESTED = "requested";
public static final String FIELD_REQUESTED_BY = "requestedBy";
public static final String FIELD_REQUESTED_COMMENT = "requestedComment";
public static final String FIELD_PROCESSED = "processed";
public static final String FIELD_PROCESSED_BY = "processedBy";
public static final String FIELD_PROCESSED_COMMENT = "processedComment";
public static final String FUNCTION_GET_MNEMONIC_PATH_DEVICE_STRUCTURE = "wip_get_mnemonic_path_device_structure";
public static final String FUNCTION_GET_MNEMONIC_PATH_SYSTEM_STRUCTURE = "wip_get_mnemonic_path_system_structure";
public static final String FUNCTION_GET_INSTANCE_INDEX = "wip_get_instance_index";
private String uuid;
private String description;
@Enumerated(EnumType.STRING)
private Status status;
private Boolean latest;
private Boolean deleted;
private Date requested;
@Column(name = "requested_by")
private String requestedBy;
@Column(name = "requested_comment")
private String requestedComment;
private Date processed;
@Column(name = "processed_by")
private String processedBy;
@Column(name = "processed_comment")
private String processedComment;
public UUID getUuid() {
return uuid != null ? UUID.fromString(uuid) : null;
}
public void setUuid(UUID uuid) {
this.uuid = uuid != null ? uuid.toString() : null;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public Boolean isLatest() {
return latest;
}
public void setLatest(Boolean latest) {
this.latest = latest;
}
public Boolean isDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public Date getRequested() {
return requested;
}
public void setRequested(Date requested) {
this.requested = requested;
}
public String getRequestedBy() {
return requestedBy;
}
public void setRequestedBy(String requestedBy) {
this.requestedBy = requestedBy;
}
public String getRequestedComment() {
return requestedComment;
}
public void setRequestedComment(String requestedComment) {
this.requestedComment = requestedComment;
}
public Date getProcessed() {
return processed;
}
public void setProcessed(Date processed) {
this.processed = processed;
}
public String getProcessedBy() {
return processedBy;
}
public void setProcessedBy(String processedBy) {
this.processedBy = processedBy;
}
public String getProcessedComment() {
return processedComment;
}
public void setProcessedComment(String processedComment) {
this.processedComment = processedComment;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals((WipNameStructure) obj);
}
public boolean equals(WipNameStructure other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
if (getUuid() == null) {
if (other.getUuid() != null)
return false;
} else if (!getUuid().equals(other.getUuid()))
return false;
if (getDescription() == null) {
if (other.getDescription() != null)
return false;
} else if (!getDescription().equals(other.getDescription()))
return false;
if (getStatus() == null) {
if (other.getStatus() != null)
return false;
} else if (!getStatus().equals(other.getStatus()))
return false;
if (isLatest() == null) {
if (other.isLatest() != null)
return false;
} else if (!isLatest().equals(other.isLatest()))
return false;
if (isDeleted() == null) {
if (other.isDeleted() != null)
return false;
} else if (!isDeleted().equals(other.isDeleted()))
return false;
if (getRequested() == null) {
if (other.getRequested() != null)
return false;
} else if (!getRequested().equals(other.getRequested()))
return false;
if (getRequestedBy() == null) {
if (other.getRequestedBy() != null)
return false;
} else if (!getRequestedBy().equals(other.getRequestedBy()))
return false;
if (getRequestedComment() == null) {
if (other.getRequestedComment() != null)
return false;
} else if (!getRequestedComment().equals(other.getRequestedComment()))
return false;
if (getProcessed() == null) {
if (other.getProcessed() != null)
return false;
} else if (!getProcessed().equals(other.getProcessed()))
return false;
if (getProcessedBy() == null) {
if (other.getProcessedBy() != null)
return false;
} else if (!getProcessedBy().equals(other.getProcessedBy()))
return false;
if (getProcessedComment() == null) {
if (other.getProcessedComment() != null)
return false;
} else if (!getProcessedComment().equals(other.getProcessedComment()))
return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import org.openepics.names.rest.beans.Status;
/**
* A superclass implementing properties required by JPA. It should be extended by
* System structure and Device structure classes that need to be persisted to the database.
*
* @author Lars Johansson
*/
@MappedSuperclass
public class WipStructure extends WipNameStructure {
public static final String FIELD_MNEMONIC = "mnemonic";
public static final String FIELD_MNEMONIC_EQUIVALENCE = "mnemonicEquivalence";
public static final String FIELD_ORDERING = "ordering";
private String mnemonic;
@Column(name = "mnemonic_equivalence")
private String mnemonicEquivalence;
private Integer ordering;
/**
* Constructor for Structure.
*/
public WipStructure() {
}
/**
* Constructor for Structure.
*
* @param uuid uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public WipStructure(UUID uuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean latest, Boolean deleted,
Date processed, String processedBy, String processedComment) {
setUuid(uuid);
setMnemonic(mnemonic);
setMnemonicEquivalence(mnemonicEquivalence);
setOrdering(ordering);
setDescription(description);
setStatus(status);
setLatest(latest);
setDeleted(deleted);
setProcessed(processed);
setProcessedBy(processedBy);
setProcessedComment(processedComment);
}
public String getMnemonic() {
return mnemonic;
}
public void setMnemonic(String mnemonic) {
this.mnemonic = mnemonic;
}
public String getMnemonicEquivalence() {
return mnemonicEquivalence;
}
public void setMnemonicEquivalence(String mnemonicEquivalence) {
this.mnemonicEquivalence = mnemonicEquivalence;
}
public Integer getOrdering() {
return ordering;
}
public void setOrdering(Integer ordering) {
this.ordering = ordering;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals((WipStructure) obj);
}
public boolean equals(WipStructure other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
if (getMnemonic() == null) {
if (other.getMnemonic() != null)
return false;
} else if (!getMnemonic().equals(other.getMnemonic()))
return false;
if (getMnemonicEquivalence() == null) {
if (other.getMnemonicEquivalence() != null)
return false;
} else if (!getMnemonicEquivalence().equals(other.getMnemonicEquivalence()))
return false;
if (getOrdering() == null) {
if (other.getOrdering() != null)
return false;
} else if (!getOrdering().equals(other.getOrdering()))
return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a subsystem name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "wip_subsystem")
public class WipSubsystem extends WipStructure {
public static final String FIELD_PARENT_UUID = "parentUuid";
public static final String FUNCTION_GET_MNEMONIC_PATH_SUBSYSTEM = "wip_get_mnemonic_path_subsystem";
@Column(name = "parent_uuid")
private String parentUuid;
/**
* Constructor for Subsystem.
*/
public WipSubsystem() {
}
/**
* Constructor for Subsystem.
*
* @param uuid uuid
* @param parentUuid parent uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public WipSubsystem(UUID uuid, UUID parentUuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean latest, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid, mnemonic, mnemonicEquivalence, ordering,
description, status, latest, deleted,
processed, processedBy, processedComment);
setParentUuid(parentUuid);
}
public UUID getParentUuid() {
return parentUuid != null ? UUID.fromString(parentUuid) : null;
}
public void setParentUuid(UUID parentUuid) {
this.parentUuid = parentUuid != null ? parentUuid.toString() : null;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((WipSubsystem) obj);
}
public boolean equals(WipSubsystem other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
if (getParentUuid() == null) {
if (other.getParentUuid() != null)
return false;
} else if (!getParentUuid().equals(other.getParentUuid()))
return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"parent_uuid\": " + getParentUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a system name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "wip_system")
public class WipSystem extends WipStructure {
public static final String FIELD_PARENT_UUID = "parentUuid";
public static final String FUNCTION_GET_MNEMONIC_PATH_SYSTEM = "wip_get_mnemonic_path_system";
@Column(name = "parent_uuid")
private String parentUuid;
/**
* Constructor for System.
*/
public WipSystem() {
}
/**
* Constructor for System.
*
* @param uuid uuid
* @param parentUuid parent uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public WipSystem(UUID uuid, UUID parentUuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean latest, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid, mnemonic, mnemonicEquivalence, ordering,
description, status, latest, deleted,
processed, processedBy, processedComment);
setParentUuid(parentUuid);
}
public UUID getParentUuid() {
return parentUuid != null ? UUID.fromString(parentUuid) : null;
}
public void setParentUuid(UUID parentUuid) {
this.parentUuid = parentUuid != null ? parentUuid.toString() : null;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((WipSystem) obj);
}
public boolean equals(WipSystem other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
if (getParentUuid() == null) {
if (other.getParentUuid() != null)
return false;
} else if (!getParentUuid().equals(other.getParentUuid()))
return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"parent_uuid\": " + getParentUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.model.wip;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.openepics.names.rest.beans.Status;
/**
* This entity represents a system group name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "wip_systemgroup")
public class WipSystemGroup extends WipStructure {
/**
* Constructor for SystemGroup.
*/
public WipSystemGroup() {
}
/**
* Constructor for SystemGroup.
*
* @param uuid uuid
* @param mnemonic mnemonic
* @param mnemonicEquivalence mnemonic equivalence
* @param ordering ordering
* @param description description
* @param status status
* @param latest latest
* @param deleted deleted
* @param processed processed
* @param processedBy processed by
* @param processedComment processed comment
*/
public WipSystemGroup(UUID uuid,
String mnemonic, String mnemonicEquivalence, Integer ordering, String description,
Status status, Boolean latest, Boolean deleted,
Date processed, String processedBy, String processedComment) {
super(uuid, mnemonic, mnemonicEquivalence, ordering,
description, status, latest, deleted,
processed, processedBy, processedComment);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((WipSystemGroup) obj);
}
public boolean equals(WipSystemGroup other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return Objects.hash(getId(), getUuid());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"version\": " + getVersion());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
sb.append(", \"ordering\": " + getOrdering());
sb.append(", \"description\": " + getDescription());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append(", \"requested\": " + getRequested());
sb.append(", \"requested_by\": " + getRequestedBy());
sb.append(", \"requested_comment\": " + getRequestedComment());
sb.append(", \"processed\": " + getProcessed());
sb.append(", \"processed_by\": " + getProcessedBy());
sb.append(", \"processed_comment\": " + getProcessedComment());
sb.append("}");
return sb.toString();
}
@Override
public String toStringSimple() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("\"id\": " + getId());
sb.append(", \"uuid\": " + getUuid());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"status\": " + getStatus());
sb.append(", \"latest\": " + isLatest());
sb.append(", \"deleted\": " + isDeleted());
sb.append("}");
return sb.toString();
}
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.wip;
import java.util.List;
import org.openepics.names.repository.model.wip.WipDeviceGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find device group structure (name part) information in JPA.
*
* @author Lars Johansson
*/
@Repository
public interface IWipDeviceGroupRepository extends JpaRepository<WipDeviceGroup, Long> {
// old + verification
@Query("FROM WipDeviceGroup dg WHERE dg.latest = true AND dg.uuid = ?1")
WipDeviceGroup findLatestByUuid(String uuid);
@Query("FROM WipDeviceGroup dg WHERE dg.uuid = ?1")
List<WipDeviceGroup> findByUuid(String uuid);
// ----------------------------------------------------------------------------------------------------
@Query("FROM WipDeviceGroup dg WHERE dg.latest = true AND dg.deleted = false AND dg.uuid = ?1")
WipDeviceGroup findLatestNotDeletedByUuid(String uuid);
@Query("FROM WipDeviceGroup dg WHERE dg.latest = true")
List<WipDeviceGroup> findLatest();
@Query("FROM WipDeviceGroup dg WHERE dg.latest = true AND dg.deleted = false")
List<WipDeviceGroup> findLatestNotDeleted();
@Query("FROM WipDeviceGroup dg WHERE dg.latest = true AND dg.deleted = false AND dg.parentUuid = ?1")
List<WipDeviceGroup> findLatestNotDeletedByParent(String uuid);
@Query("FROM WipDeviceGroup dg WHERE dg.uuid = ?1 AND dg.id < ?2 ORDER BY dg.id DESC")
List<WipDeviceGroup> findPreviousByUuidAndId(String uuid, Long id);
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.wip;
import java.util.List;
import org.openepics.names.repository.model.wip.WipDeviceType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find device type structure (name part) information in JPA.
*
* @author Lars Johansson
*/
@Repository
public interface IWipDeviceTypeRepository extends JpaRepository<WipDeviceType, Long> {
// old + verification
@Query("FROM WipDeviceType dt WHERE dt.uuid = ?1")
List<WipDeviceType> findByUuid(String uuid);
@Query("FROM WipDeviceType dt WHERE dt.latest = true AND dt.mnemonic = ?1")
List<WipDeviceType> findLatestByMnemonic(String mnemonic);
// ----------------------------------------------------------------------------------------------------
@Query("FROM WipDeviceType dt WHERE dt.latest = true AND dt.uuid = ?1")
WipDeviceType findLatestByUuid(String uuid);
@Query("FROM WipDeviceType dt WHERE dt.latest = true AND dt.deleted = false AND dt.uuid = ?1")
WipDeviceType findLatestNotDeletedByUuid(String uuid);
@Query("FROM WipDeviceType dt WHERE dt.latest = true")
List<WipDeviceType> findLatest();
@Query("FROM WipDeviceType dt WHERE dt.latest = true AND dt.deleted = false")
List<WipDeviceType> findLatestNotDeleted();
@Query("FROM WipDeviceType dt WHERE dt.latest = true AND dt.deleted = false AND dt.parentUuid = ?1")
List<WipDeviceType> findLatestNotDeletedByParent(String uuid);
@Query("FROM WipDeviceType dt WHERE dt.uuid = ?1 AND dt.id < ?2 ORDER BY dt.id DESC")
List<WipDeviceType> findPreviousByUuidAndId(String uuid, Long id);
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.wip;
import java.util.List;
import org.openepics.names.repository.model.wip.WipDiscipline;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find discipline structure (name part) information in JPA.
*
* @author Lars Johansson
*/
@Repository
public interface IWipDisciplineRepository extends JpaRepository<WipDiscipline, Long> {
// old + verification
@Query("FROM WipDiscipline di WHERE di.latest = true AND di.uuid = ?1")
WipDiscipline findLatestByUuid(String uuid);
@Query("FROM WipDiscipline di WHERE di.uuid = ?1")
List<WipDiscipline> findByUuid(String uuid);
@Query("FROM WipDiscipline di WHERE di.latest = true AND di.mnemonic = ?1")
List<WipDiscipline> findLatestByMnemonic(String mnemonic);
// ----------------------------------------------------------------------------------------------------
@Query("FROM WipDiscipline di WHERE di.latest = true AND di.deleted = false AND di.mnemonic = ?1")
WipDiscipline findLatestNotDeletedByMnemonic(String mnemonic);
@Query("FROM WipDiscipline di WHERE di.latest = true AND di.deleted = false AND di.uuid = ?1")
WipDiscipline findLatestNotDeletedByUuid(String uuid);
@Query("FROM WipDiscipline di WHERE di.latest = true")
List<WipDiscipline> findLatest();
@Query("FROM WipDiscipline di WHERE di.latest = true AND di.deleted = false")
List<WipDiscipline> findLatestNotDeleted();
@Query("FROM WipDiscipline di WHERE di.uuid = ?1 AND di.id < ?2 ORDER BY di.id DESC")
List<WipDiscipline> findPreviousByUuidAndId(String uuid, Long id);
}
/*
* Copyright (C) 2021 European Spallation Source ERIC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openepics.names.repository.wip;
import java.util.Date;
import java.util.List;
import org.openepics.names.repository.model.wip.WipName;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find name information in JPA.
*
* @author Lars Johansson
*/
@Repository
public interface IWipNameRepository extends JpaRepository<WipName, Long> {
// old + verification
@Query("FROM WipName n WHERE n.latest = true AND n.conventionName = ?1")
WipName findLatestByConventionName(String conventionName);
@Query("FROM WipName n WHERE n.latest = true")
List<WipName> findLatest();
@Query("FROM WipName n WHERE n.latest = true AND n.deleted = false")
List<WipName> findLatestNotDeleted();
@Query("SELECT n FROM WipName n, WipSystemGroup sg "
+ "WHERE n.latest = true "
+ "AND sg.uuid = n.systemGroupUuid "
+ "AND sg.latest = true "
+ "AND sg.mnemonic = ?1")
List<WipName> findLatestBySystemGroupMnemonic(String mnemonic);
@Query("SELECT n FROM WipName n, WipSystem sys "
+ "WHERE n.latest = true "
+ "AND sys.uuid = n.systemUuid "
+ "AND sys.latest = true "
+ "AND sys.mnemonic = ?1")
List<WipName> findLatestBySystemMnemonic(String mnemonic);
@Query("SELECT n FROM WipName n, WipSubsystem sub, WipSystem sys "
+ "WHERE n.latest = true "
+ "AND sub.uuid = n.subsystemUuid "
+ "AND sub.latest = true "
+ "AND sys.uuid = sub.parentUuid "
+ "AND sys.latest = true "
+ "AND sys.mnemonic = ?1")
List<WipName> findLatestBySystemMnemonicThroughSubsystem(String mnemonic);
@Query("SELECT n FROM WipName n, WipSubsystem sub "
+ "WHERE n.latest = true "
+ "AND sub.uuid = n.subsystemUuid "
+ "AND sub.latest = true "
+ "AND sub.mnemonic = ?1")
List<WipName> findLatestBySubsystemMnemonic(String mnemonic);
@Query("SELECT n FROM WipName n, WipDeviceType dt, WipDeviceGroup dg, WipDiscipline di "
+ "WHERE n.latest = true "
+ "AND dt.uuid = n.deviceTypeUuid "
+ "AND dt.latest = true "
+ "AND dg.uuid = dt.parentUuid "
+ "AND dg.latest = true "
+ "AND di.uuid = dg.parentUuid "
+ "AND di.latest = true "
+ "AND di.mnemonic = ?1")
List<WipName> findLatestByDisciplineMnemonicThroughDeviceType(String mnemonic);
@Query("SELECT n FROM WipName n, WipDeviceType dt "
+ "WHERE n.latest = true "
+ "AND dt.uuid = n.deviceTypeUuid "
+ "AND dt.latest = true "
+ "AND dt.mnemonic = ?1")
List<WipName> findLatestByDeviceTypeMnemonic(String mnemonic);
// ----------------------------------------------------------------------------------------------------
@Query("FROM WipName n WHERE n.latest = true AND n.uuid = ?1")
WipName findLatestByUuid(String uuid);
@Query("FROM WipName n WHERE n.uuid = ?1")
List<WipName> findByUuid(String uuid);
// ----------------------------------------------------------------------------------------------------
@Query("SELECT n FROM WipName n, WipSystemGroup sg "
+ "WHERE n.latest = true "
+ "AND n.deleted = false "
+ "AND sg.uuid = n.systemGroupUuid "
+ "AND sg.latest = true "
+ "AND sg.uuid = ?1")
List<WipName> findLatestNotDeletedBySystemGroupUuid(String uuid);
@Query("SELECT n FROM WipName n, WipSystem sys "
+ "WHERE n.latest = true "
+ "AND n.deleted = false "
+ "AND sys.uuid = n.systemUuid "
+ "AND sys.latest = true "
+ "AND sys.uuid = ?1")
List<WipName> findLatestNotDeletedBySystemUuid(String uuid);
@Query("SELECT n FROM WipName n, WipSubsystem sub, WipSystem sys "
+ "WHERE n.latest = true "
+ "AND n.deleted = false "
+ "AND sub.uuid = n.subsystemUuid "
+ "AND sub.latest = true "
+ "AND sys.uuid = sub.parentUuid "
+ "AND sys.latest = true "
+ "AND sys.uuid = ?1")
List<WipName> findLatestNotDeletedBySystemUuidThroughSubsystem(String uuid);
@Query("SELECT n FROM WipName n, WipSubsystem sub "
+ "WHERE n.latest = true "
+ "AND n.deleted = false "
+ "AND sub.uuid = n.subsystemUuid "
+ "AND sub.latest = true "
+ "AND sub.uuid = ?1")
List<WipName> findLatestNotDeletedBySubsystemUuid(String uuid);
@Query("SELECT n FROM WipName n, WipDeviceType dt, WipDeviceGroup dg, WipDiscipline di "
+ "WHERE n.latest = true "
+ "AND n.deleted = false "
+ "AND dt.uuid = n.deviceTypeUuid "
+ "AND dt.latest = true "
+ "AND dg.uuid = dt.parentUuid "
+ "AND dg.latest = true "
+ "AND di.uuid = dg.parentUuid "
+ "AND di.latest = true "
+ "AND di.uuid = ?1")
List<WipName> findLatestNotDeletedByDisciplineUuidThroughDeviceType(String uuid);
@Query("SELECT n FROM WipName n, WipDeviceType dt "
+ "WHERE n.latest = true "
+ "AND n.deleted = false "
+ "AND dt.uuid = n.deviceTypeUuid "
+ "AND dt.latest = true "
+ "AND dt.uuid = ?1")
List<WipName> findLatestNotDeletedByDeviceTypeUuid(String uuid);
// ----------------------------------------------------------------------------------------------------
@Query("FROM WipName n WHERE n.requested >= ?1 AND n.requested <= ?2")
List<WipName> findByRequestedBetween(Date from, Date to);
}