Skip to content
Snippets Groups Projects
Commit 29bc3796 authored by Lars Johansson's avatar Lars Johansson
Browse files

Added existing REST API endpoints - deviceNames, healthcheck, history, parts - for proof-of-concept

parent 3d08485b
No related branches found
No related tags found
No related merge requests found
Showing
with 1939 additions and 0 deletions
/*
* Copyright (c) 2016 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.old.business;
import org.openepics.names.old.model.NamePartRevisionStatus;
/**
* Enum that handles the status of a revision.
*
* @author karinrathsman
*
*/
public enum NameRevisionStatus {
APPROVED(),
CANCELLED(),
PENDING(),
REJECTED();
static NameRevisionStatus get(NamePartRevisionStatus status) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
/**
*
* @return true if the revision is unapproved and pending
*/
public boolean isPending() {
return equals(PENDING);
}
/**
*
* @return true if the revision approved
*/
public boolean isApproved() {
return equals(APPROVED);
}
/**
*
* @return true if the revision is unapproved and cancelled or rejcted
*/
public boolean isCancelled() {
return equals(CANCELLED) || equals(REJECTED);
}
/**
*
* @return true if the revision is unapproved and rejcted
*/
public boolean isRejected() {
return equals(REJECTED);
}
}
/*-
* Copyright (c) 2014 European Spallation Source ERIC.
* Copyright (c) 2014 Cosylab d.d.
*
* This file is part of Naming Service.
* Naming Service 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 any newer 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, see https://www.gnu.org/licenses/gpl-2.0.txt
*/
package org.openepics.names.old.model;
import org.openepics.names.old.business.NameRevisionStatus;
/**
* Status of the name part in the request / approve workflow.
*
* @author Marko Kolar
*/
public enum NamePartRevisionStatus {
/**
* The proposed revision has been approved by the administrator.
*/
APPROVED,
/**
* The proposed revision has been cancelled by the user that requested it.
*/
CANCELLED,
/**
* The proposed revision is pending approval by the administrator.
*/
PENDING,
/**
* The proposed revision has been rejected by the administrator.
*/
REJECTED;
/**
* Convert NamePartRevisionStatus to NameRevisionStatus.
*
* @param status NamePartRevisionStatus
* @return NameRevisionStatus
*/
public static NameRevisionStatus asNameRevisionStatus(NamePartRevisionStatus status) {
switch (status) {
case APPROVED:
return NameRevisionStatus.APPROVED;
case CANCELLED:
return NameRevisionStatus.CANCELLED;
case REJECTED:
return NameRevisionStatus.REJECTED;
default:
return NameRevisionStatus.PENDING;
}
}
/**
* Convert NameRevisionStatus to NamePartRevisionStatus.
*
* @param status NameRevisionStatus
* @return NamePartRevisionStatus
*/
public static NamePartRevisionStatus get(NameRevisionStatus status) {
switch (status) {
case APPROVED:
return APPROVED;
case CANCELLED:
return CANCELLED;
case REJECTED:
return REJECTED;
default:
return PENDING;
}
}
}
/*
* 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;
import java.util.List;
import org.openepics.names.repository.model.DeviceGroup;
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 from JPA.
*
* @author Lars Johansson
*/
@Repository
public interface IDeviceGroupRepository extends JpaRepository<DeviceGroup, Long> {
@Query("FROM DeviceGroup dg WHERE dg.latest = true AND dg.uuid = ?1")
DeviceGroup findLatestByUuid(String uuid);
@Query("FROM DeviceGroup dg WHERE dg.latest = true AND dg.deleted = false AND dg.mnemonic = ?1")
DeviceGroup findLatestNotDeletedByMnemonic(String mnemonic);
@Query("FROM DeviceGroup dg WHERE dg.latest = true AND dg.deleted = false AND dg.uuid = ?1")
DeviceGroup findLatestNotDeletedByUuid(String uuid);
@Query("FROM DeviceGroup dg WHERE dg.latest = true AND dg.deleted = false AND dg.parent_uuid = ?1 and dg.mnemonic = ?2")
DeviceGroup findLatestNotDeletedByParentAndMnemonic(String uuid, String mnemonic);
@Query("FROM DeviceGroup dg WHERE dg.uuid = ?1")
List<DeviceGroup> findByUuid(String uuid);
@Query("FROM DeviceGroup dg WHERE dg.latest = true")
List<DeviceGroup> findLatest();
@Query("FROM DeviceGroup dg WHERE dg.latest = true AND dg.mnemonic = ?1")
List<DeviceGroup> findLatestByMnemonic(String mnemonic);
@Query("FROM DeviceGroup dg WHERE dg.latest = true AND dg.deleted = false")
List<DeviceGroup> findLatestNotDeleted();
@Query("FROM DeviceGroup dg WHERE dg.latest = true AND dg.deleted = false AND dg.parent_uuid = ?1")
List<DeviceGroup> findLatestNotDeletedByParent(String uuid);
}
/*
* 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;
import java.util.List;
import org.openepics.names.repository.model.DeviceType;
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 from JPA.
*
* @author Lars Johansson
*/
@Repository
public interface IDeviceTypeRepository extends JpaRepository<DeviceType, Long> {
@Query("FROM DeviceType dt WHERE dt.latest = true AND dt.uuid = ?1")
DeviceType findLatestByUuid(String uuid);
@Query("FROM DeviceType dt WHERE dt.latest = true AND dt.deleted = false AND dt.mnemonic = ?1")
DeviceType findLatestNotDeletedByMnemonic(String mnemonic);
@Query("FROM DeviceType dt WHERE dt.latest = true AND dt.deleted = false AND dt.uuid = ?1")
DeviceType findLatestNotDeletedByUuid(String uuid);
@Query("FROM DeviceType dt WHERE dt.latest = true AND dt.deleted = false AND dt.parent_uuid = ?1 and dt.mnemonic = ?2")
DeviceType findLatestNotDeletedByParentAndMnemonic(String uuid, String mnemonic);
@Query("FROM DeviceType dt WHERE dt.uuid = ?1")
List<DeviceType> findByUuid(String uuid);
@Query("FROM DeviceType dt WHERE dt.latest = true")
List<DeviceType> findLatest();
@Query("FROM DeviceType dt WHERE dt.latest = true AND dt.mnemonic = ?1")
List<DeviceType> findLatestByMnemonic(String mnemonic);
@Query("FROM DeviceType dt WHERE dt.latest = true AND dt.deleted = false")
List<DeviceType> findLatestNotDeleted();
@Query("FROM DeviceType dt WHERE dt.latest = true AND dt.deleted = false AND dt.parent_uuid = ?1")
List<DeviceType> findLatestNotDeletedByParent(String uuid);
}
/*
* 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;
import java.util.List;
import org.openepics.names.repository.model.Discipline;
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 from JPA.
*
* @author Lars Johansson
*/
@Repository
public interface IDisciplineRepository extends JpaRepository<Discipline, Long> {
@Query("FROM Discipline di WHERE di.latest = true AND di.uuid = ?1")
Discipline findLatestByUuid(String uuid);
@Query("FROM Discipline di WHERE di.latest = true AND di.deleted = false AND di.mnemonic = ?1")
Discipline findLatestNotDeletedByMnemonic(String mnemonic);
@Query("FROM Discipline di WHERE di.latest = true AND di.deleted = false AND di.uuid = ?1")
Discipline findLatestNotDeletedByUuid(String uuid);
@Query("FROM Discipline di WHERE di.uuid = ?1")
List<Discipline> findByUuid(String uuid);
@Query("FROM Discipline di WHERE di.latest = true")
List<Discipline> findLatest();
@Query("FROM Discipline di WHERE di.latest = true AND di.mnemonic = ?1")
List<Discipline> findLatestByMnemonic(String mnemonic);
@Query("FROM Discipline di WHERE di.latest = true AND di.deleted = false")
List<Discipline> findLatestNotDeleted();
}
/*
* 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;
import java.util.List;
import org.openepics.names.repository.model.Name;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find name information from JPA.
*
* @author Lars Johansson
*/
@Repository
public interface INameRepository extends JpaRepository<Name, Long> {
@Query("FROM Name n WHERE n.latest = true AND n.uuid = ?1")
Name findLatestByUuid(String uuid);
@Query("FROM Name n WHERE n.latest = true AND n.convention_name = ?1")
Name findLatestByConventionName(String conventionName);
@Query("FROM Name n WHERE n.uuid = ?1")
List<Name> findByUuid(String uuid);
@Query("FROM Name n WHERE n.latest = true")
List<Name> findLatest();
@Query("FROM Name n WHERE n.latest = true AND n.deleted = false")
List<Name> findLatestNotDeleted();
@Query("SELECT n FROM Name n, SystemGroup sg "
+ "WHERE n.latest = true "
+ "AND sg.uuid = n.systemgroup_uuid "
+ "AND sg.latest = true "
+ "AND sg.mnemonic = ?1")
List<Name> findLatestBySystemGroupMnemonic(String mnemonic);
@Query("SELECT n FROM Name n, System sys "
+ "WHERE n.latest = true "
+ "AND sys.uuid = n.system_uuid "
+ "AND sys.latest = true "
+ "AND sys.mnemonic = ?1")
List<Name> findLatestBySystemMnemonic(String mnemonic);
@Query("SELECT n FROM Name n, Subsystem sub, System sys "
+ "WHERE n.latest = true "
+ "AND sub.uuid = n.subsystem_uuid "
+ "AND sub.latest = true "
+ "AND sys.uuid = sub.parent_uuid "
+ "AND sys.latest = true "
+ "AND sys.mnemonic = ?1")
List<Name> findLatestBySystemMnemonicThroughSubsystem(String mnemonic);
@Query("SELECT n FROM Name n, Subsystem sub "
+ "WHERE n.latest = true "
+ "AND sub.uuid = n.subsystem_uuid "
+ "AND sub.latest = true "
+ "AND sub.mnemonic = ?1")
List<Name> findLatestBySubsystemMnemonic(String mnemonic);
@Query("SELECT n FROM Name n, DeviceType dt, DeviceGroup dg, Discipline di "
+ "WHERE n.latest = true "
+ "AND dt.uuid = n.devicetype_uuid "
+ "AND dt.latest = true "
+ "AND dg.uuid = dt.parent_uuid "
+ "AND dg.latest = true "
+ "AND di.uuid = dg.parent_uuid "
+ "AND di.latest = true "
+ "AND di.mnemonic = ?1")
List<Name> findLatestByDisciplineMnemonic(String mnemonic);
@Query("SELECT n FROM Name n, DeviceType dt "
+ "WHERE n.latest = true "
+ "AND dt.uuid = n.devicetype_uuid "
+ "AND dt.latest = true "
+ "AND dt.mnemonic = ?1")
List<Name> findLatestByDeviceTypeMnemonic(String mnemonic);
}
/*
* 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;
import java.util.List;
import org.openepics.names.repository.model.Subsystem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find subsystem structure (name part)information from JPA.
*
* @author Lars Johansson
*/
@Repository
public interface ISubsystemRepository extends JpaRepository<Subsystem, Long> {
@Query("FROM Subsystem sub WHERE sub.latest = true AND sub.uuid = ?1")
Subsystem findLatestByUuid(String uuid);
@Query("FROM Subsystem sub WHERE sub.latest = true AND sub.deleted = false AND sub.mnemonic = ?1")
Subsystem findLatestNotDeletedByMnemonic(String mnemonic);
@Query("FROM Subsystem sub WHERE sub.latest = true AND sub.deleted = false AND sub.uuid = ?1")
Subsystem findLatestNotDeletedByUuid(String uuid);
@Query("FROM Subsystem sub WHERE sub.latest = true AND sub.deleted = false AND sub.parent_uuid = ?1 and sub.mnemonic = ?2")
Subsystem findLatestNotDeletedByParentAndMnemonic(String uuid, String mnemonic);
@Query("FROM Subsystem sub WHERE sub.uuid = ?1")
List<Subsystem> findByUuid(String uuid);
@Query("FROM Subsystem sub WHERE sub.latest = true")
List<Subsystem> findLatest();
@Query("FROM Subsystem sub WHERE sub.latest = true AND sub.mnemonic = ?1")
List<Subsystem> findLatestByMnemonic(String mnemonic);
@Query("FROM Subsystem sub WHERE sub.latest = true AND sub.deleted = false")
List<Subsystem> findLatestNotDeleted();
@Query("FROM Subsystem sub WHERE sub.latest = true AND sub.deleted = false AND sub.parent_uuid = ?1")
List<Subsystem> findLatestNotDeletedByParent(String uuid);
}
/*
* 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;
import java.util.List;
import org.openepics.names.repository.model.SystemGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find system group structure (name part) information from JPA.
*
* @author Lars Johansson
*/
@Repository
public interface ISystemGroupRepository extends JpaRepository<SystemGroup, Long> {
@Query("FROM SystemGroup sg WHERE sg.latest = true AND sg.uuid = ?1")
SystemGroup findLatestByUuid(String uuid);
@Query("FROM SystemGroup sg WHERE sg.latest = true AND sg.deleted = false AND sg.mnemonic = ?1")
SystemGroup findLatestNotDeletedByMnemonic(String mnemonic);
@Query("FROM SystemGroup sg WHERE sg.latest = true AND sg.deleted = false AND sg.uuid = ?1")
SystemGroup findLatestNotDeletedByUuid(String uuid);
@Query("FROM SystemGroup sg WHERE sg.uuid = ?1")
List<SystemGroup> findByUuid(String uuid);
@Query("FROM SystemGroup sg WHERE sg.latest = true")
List<SystemGroup> findLatest();
@Query("FROM SystemGroup sg WHERE sg.latest = true AND sg.mnemonic = ?1")
List<SystemGroup> findLatestByMnemonic(String mnemonic);
@Query("FROM SystemGroup sg WHERE sg.latest = true AND sg.deleted = false")
List<SystemGroup> findLatestNotDeleted();
}
/*
* 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;
import java.util.List;
import org.openepics.names.repository.model.System;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
/**
* Find system structure (name part) information from JPA.
*
* @author Lars Johansson
*/
@Repository
public interface ISystemRepository extends JpaRepository<System, Long> {
@Query("FROM System sys WHERE sys.latest = true AND sys.uuid = ?1")
System findLatestByUuid(String uuid);
@Query("FROM System sys WHERE sys.latest = true AND sys.deleted = false AND sys.mnemonic = ?1")
System findLatestNotDeletedByMnemonic(String mnemonic);
@Query("FROM System sys WHERE sys.latest = true AND sys.deleted = false AND sys.uuid = ?1")
System findLatestNotDeletedByUuid(String uuid);
@Query("FROM System sys WHERE sys.latest = true AND sys.deleted = false AND sys.parent_uuid = ?1 and sys.mnemonic = ?2")
System findLatestNotDeletedByParentAndMnemonic(String uuid, String mnemonic);
@Query("FROM System sys WHERE sys.uuid = ?1")
List<System> findByUuid(String uuid);
@Query("FROM System sys WHERE sys.latest = true")
List<System> findLatest();
@Query("FROM System sys WHERE sys.latest = true AND sys.mnemonic = ?1")
List<System> findLatestByMnemonic(String mnemonic);
@Query("FROM System sys WHERE sys.latest = true AND sys.deleted = false")
List<System> findLatestNotDeleted();
@Query("FROM System sys WHERE sys.latest = true AND sys.deleted = false AND sys.parent_uuid = ?1")
List<System> findLatestNotDeletedByParent(String uuid);
}
/*
* 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;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* This entity represents a device group name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "devicegroup")
public class DeviceGroup extends Structure {
/**
*
*/
private static final long serialVersionUID = -8762287473417706804L;
private String parent_uuid;
public UUID getParentUuid() {
return parent_uuid != null ? UUID.fromString(parent_uuid) : null;
}
public void setParentUuid(UUID parent_uuid) {
this.parent_uuid = parent_uuid != null ? parent_uuid.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 ((DeviceGroup) obj);
}
public boolean equals(DeviceGroup 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;
}
public boolean equalsId(Object other) {
return other instanceof DeviceGroup && ((DeviceGroup) other).getId().equals(getId());
}
@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(", \"name\": " + getName());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
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;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* This entity represents a device type name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "devicetype")
public class DeviceType extends Structure {
/**
*
*/
private static final long serialVersionUID = 2061731870402041740L;
private String parent_uuid;
public UUID getParentUuid() {
return parent_uuid != null ? UUID.fromString(parent_uuid) : null;
}
public void setParentUuid(UUID parent_uuid) {
this.parent_uuid = parent_uuid != null ? parent_uuid.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 ((DeviceType) obj);
}
public boolean equals(DeviceType 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;
}
public boolean equalsId(Object other) {
return other instanceof DeviceType && ((DeviceType) other).getId().equals(getId());
}
@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(", \"name\": " + getName());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
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;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* This entity represents a discipline name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "discipline")
public class Discipline extends Structure {
/**
*
*/
private static final long serialVersionUID = 8729921221024362502L;
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((Discipline) obj);
}
public boolean equals(Discipline other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
return true;
}
public boolean equalsId(Object other) {
return other instanceof Discipline && ((Discipline) other).getId().equals(getId());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
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(", \"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;
import java.io.Serializable;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* This entity represents a name.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "name")
public class Name extends NameStructure implements Serializable {
/**
*
*/
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 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;
}
public String getInstanceIndex() {
return instance_index;
}
public void setInstanceIndex(String instance_index) {
this.instance_index = instance_index;
}
public String getConventionName() {
return convention_name;
}
public void setConventionName(String convention_name) {
this.convention_name = convention_name;
}
public String getConventionNameEquivalence() {
return convention_name_equivalence;
}
public void setConventionNameEquivalence(String convention_name_equivalence) {
this.convention_name_equivalence = convention_name_equivalence;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((Name) obj);
}
public boolean equals(Name 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;
}
public boolean equalsId(Object other) {
return other instanceof Name && ((Name) other).getId().equals(getId());
}
@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;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.MappedSuperclass;
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 NameStructure extends Persistable implements Serializable {
/**
*
*/
private static final long serialVersionUID = 736094142259082938L;
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;
private Date processed;
private String processed_by;
private String processed_comment;
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 requested_by;
}
public void setRequestedBy(String requested_by) {
this.requested_by = requested_by;
}
public String getRequestedComment() {
return requested_comment;
}
public void setRequestedComment(String requested_comment) {
this.requested_comment = requested_comment;
}
public Date getProcessed() {
return processed;
}
public void setProcessed(Date processed) {
this.processed = processed;
}
public String getProcessedBy() {
return processed_by;
}
public void setProcessedBy(String processed_by) {
this.processed_by = processed_by;
}
public String getProcessedComment() {
return processed_comment;
}
public void setProcessedComment(String processed_comment) {
this.processed_comment = processed_comment;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals((NameStructure) obj);
}
public boolean equals(NameStructure 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;
}
public boolean equalsId(Object other) {
return other instanceof NameStructure && ((NameStructure) other).getId().equals(getId());
}
@Override
public int hashCode() {
return Objects.hash(getUuid());
}
}
/*-
* Copyright (c) 2014 European Spallation Source ERIC.
* Copyright (c) 2014 Cosylab d.d.
*
* This file is part of Naming Service.
* Naming Service 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 any newer 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, see https://www.gnu.org/licenses/gpl-2.0.txt
*/
package org.openepics.names.repository.model;
import javax.annotation.Nullable;
import javax.persistence.*;
import java.io.Serializable;
/**
* A superclass implementing the properties required by JPA. It that should be extended by all classes that need to be
* persisted to the database.
*
* @author Marko Kolar
*/
@MappedSuperclass
public class Persistable implements Serializable {
private static final long serialVersionUID = 8393161299438204843L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected @Nullable Long id;
@Version
private @Nullable Integer version;
/**
* The JPA entity ID.
* @return JPA entity id
*/
public @Nullable Long getId() { return id; }
/**
* The JPA entity version.
* @return The JPA entity version
*/
public @Nullable Integer getVersion() { return version; }
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals((Persistable) obj);
}
public boolean equals(Persistable other) {
if (other == null)
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.equals(other.version))
return false;
return true;
}
}
/*
* 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;
import java.io.Serializable;
import javax.persistence.MappedSuperclass;
/**
* 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 Structure extends NameStructure implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5980090194197159918L;
private String name;
private String mnemonic;
private String mnemonic_equivalence;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMnemonic() {
return mnemonic;
}
public void setMnemonic(String mnemonic) {
this.mnemonic = mnemonic;
}
public String getMnemonicEquivalence() {
return mnemonic_equivalence;
}
public void setMnemonicEquivalence(String mnemonic_equivalence) {
this.mnemonic_equivalence = mnemonic_equivalence;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals((Structure) obj);
}
public boolean equals(Structure other) {
if (other == null)
return false;
if (!super.equals(other)) {
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;
} 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;
return true;
}
public boolean equalsId(Object other) {
return other instanceof Structure && ((Structure) other).getId().equals(getId());
}
}
/*
* 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;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* This entity represents a subsystem name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "subsystem")
public class Subsystem extends Structure {
/**
*
*/
private static final long serialVersionUID = 5662135540008222500L;
private String parent_uuid;
public UUID getParentUuid() {
return parent_uuid != null ? UUID.fromString(parent_uuid) : null;
}
public void setParentUuid(UUID parent_uuid) {
this.parent_uuid = parent_uuid != null ? parent_uuid.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 ((Subsystem) obj);
}
public boolean equals(Subsystem 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;
}
public boolean equalsId(Object other) {
return other instanceof Subsystem && ((Subsystem) other).getId().equals(getId());
}
@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(", \"name\": " + getName());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
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;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* This entity represents a system name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "system")
public class System extends Structure {
/**
*
*/
private static final long serialVersionUID = -4323438470765348486L;
private String parent_uuid;
public UUID getParentUuid() {
return parent_uuid != null ? UUID.fromString(parent_uuid) : null;
}
public void setParentUuid(UUID parent_uuid) {
this.parent_uuid = parent_uuid != null ? parent_uuid.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 ((System) obj);
}
public boolean equals(System 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;
}
public boolean equalsId(Object other) {
return other instanceof System && ((System) other).getId().equals(getId());
}
@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(", \"name\": " + getName());
sb.append(", \"mnemonic\": " + getMnemonic());
sb.append(", \"mnemonic_equivalence\": " + getMnemonicEquivalence());
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;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* This entity represents a system group name part.
*
* @author Lars Johansson
*/
@Entity
@Table(name = "systemgroup")
public class SystemGroup extends Structure {
/**
*
*/
private static final long serialVersionUID = 6298835206366539021L;
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return equals ((SystemGroup) obj);
}
public boolean equals(SystemGroup other) {
if (other == null)
return false;
if (!super.equals(other)) {
return false;
}
return true;
}
public boolean equalsId(Object other) {
return other instanceof SystemGroup && ((SystemGroup) other).getId().equals(getId());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
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(", \"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.rest.beans;
/**
* This enum represents status for names and structures data in beans and for communication.
*
* @author Lars Johansson
*/
public enum Status {
APPROVED,
ARCHIVED,
CANCELLED,
PENDING,
REJECTED;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment