Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion container/oracle/initdb.d/02_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,25 @@ CREATE TABLE SIM_OWNER.SOFTWARE
HOME_URL VARCHAR2(256 CHAR) NULL,
MAINTAINER_USERNAME_CSV VARCHAR2(256 CHAR) NULL,
ARCHIVED_YN VARCHAR2(1 CHAR) DEFAULT 'N' NOT NULL,
OPS_IMPACT SMALLINT DEFAULT 3 NOT NULL,
PAST_DOWNTIME SMALLINT DEFAULT 3 NOT NULL,
DEBUGGABILITY_N_TESTING SMALLINT DEFAULT 3 NOT NULL,
CODE_COMPLEXITY SMALLINT DEFAULT 3 NOT NULL,
DOCUMENTATION_GAPS SMALLINT DEFAULT 3 NOT NULL,
ESOTERICISM SMALLINT DEFAULT 3 NOT NULL,
DOWN_PROBABILITY SMALLINT GENERATED ALWAYS AS ((PAST_DOWNTIME + DEBUGGABILITY_N_TESTING + CODE_COMPLEXITY + DOCUMENTATION_GAPS + ESOTERICISM) / 5) VIRTUAL,
DOWNTIME_RISK SMALLINT GENERATED ALWAYS AS (((PAST_DOWNTIME + DEBUGGABILITY_N_TESTING + CODE_COMPLEXITY + DOCUMENTATION_GAPS + ESOTERICISM) / 5) + OPS_IMPACT) VIRTUAL,
CONSTRAINT SOFTWARE_PK PRIMARY KEY (SOFTWARE_ID),
CONSTRAINT SOFTWARE_AK1 UNIQUE (NAME, REPOSITORY_ID),
CONSTRAINT SOFTWARE_FK1 FOREIGN KEY (REPOSITORY_ID) REFERENCES SIM_OWNER.REPOSITORY (REPOSITORY_ID),
CONSTRAINT SOFTWARE_CK1 CHECK (TYPE IN ('APP', 'LIB', 'SCRIPT', 'PLUGIN')),
CONSTRAINT SOFTWARE_CK2 CHECK (ARCHIVED_YN IN ('Y', 'N'))
CONSTRAINT SOFTWARE_CK2 CHECK (ARCHIVED_YN IN ('Y', 'N')),
CONSTRAINT SOFTWARE_CK3 CHECK (OPS_IMPACT IN (1, 2, 3, 4, 5)),
CONSTRAINT SOFTWARE_CK4 CHECK (PAST_DOWNTIME IN (1, 2, 3, 4, 5)),
CONSTRAINT SOFTWARE_CK5 CHECK (DEBUGGABILITY_N_TESTING IN (1, 2, 3, 4, 5)),
CONSTRAINT SOFTWARE_CK6 CHECK (CODE_COMPLEXITY IN (1, 2, 3, 4, 5)),
CONSTRAINT SOFTWARE_CK7 CHECK (DOCUMENTATION_GAPS IN (1, 2, 3, 4, 5)),
CONSTRAINT SOFTWARE_CK8 CHECK (ESOTERICISM IN (1, 2, 3, 4, 5))
);

CREATE TABLE SIM_OWNER.TOPIC
Expand Down
34 changes: 32 additions & 2 deletions src/main/java/org/jlab/sim/business/service/SoftwareService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import org.jlab.sim.persistence.entity.Repository;
import org.jlab.sim.persistence.entity.Software;
import org.jlab.sim.persistence.entity.SoftwareTopic;
import org.jlab.sim.persistence.enumeration.Include;
import org.jlab.sim.persistence.enumeration.SoftwareType;
import org.jlab.sim.persistence.enumeration.*;
import org.jlab.smoothness.business.exception.UserFriendlyException;
import org.jlab.smoothness.business.service.JPAService;

Expand Down Expand Up @@ -122,6 +121,37 @@ public void editSoftware(
softwareTopicService.set(software, topicArray);
}

@RolesAllowed({"sim-admin", "acg"})
public void editSoftwareRisk(
BigInteger softwareId,
OpsImpact impact,
PastDowntimeRate rate,
DebugTestDifficulty difficulty,
CodeComplexity complexity,
DocumentationGaps gaps,
Esotericism esotericism)
throws UserFriendlyException {

if (softwareId == null) {
throw new UserFriendlyException("softwareId cannot be empty");
}

Software software = find(softwareId);

if (software == null) {
throw new UserFriendlyException("software not found with id: " + softwareId);
}

software.setImpact(impact);
software.setRate(rate);
software.setDifficulty(difficulty);
software.setComplexity(complexity);
software.setGaps(gaps);
software.setEsotericism(esotericism);

edit(software);
}

@RolesAllowed({"sim-admin", "acg"})
public void removeSoftware(BigInteger softwareId) throws UserFriendlyException {
if (softwareId == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.CodeComplexity;

@Converter(autoApply = true)
public class CodeComplexityConverter implements AttributeConverter<CodeComplexity, Integer> {

@Override
public Integer convertToDatabaseColumn(CodeComplexity obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public CodeComplexity convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return CodeComplexity.fromValue(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.DebugTestDifficulty;

@Converter(autoApply = true)
public class DebugTestDifficultyConverter
implements AttributeConverter<DebugTestDifficulty, Integer> {

@Override
public Integer convertToDatabaseColumn(DebugTestDifficulty obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public DebugTestDifficulty convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return DebugTestDifficulty.fromValue(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.DocumentationGaps;

@Converter(autoApply = true)
public class DocumentationGapsConverter implements AttributeConverter<DocumentationGaps, Integer> {

@Override
public Integer convertToDatabaseColumn(DocumentationGaps obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public DocumentationGaps convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return DocumentationGaps.fromValue(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.DowntimeProbability;

@Converter(autoApply = true)
public class DowntimeProbabilityConverter
implements AttributeConverter<DowntimeProbability, Integer> {

@Override
public Integer convertToDatabaseColumn(DowntimeProbability obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public DowntimeProbability convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return DowntimeProbability.fromValue(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.DowntimeRisk;

@Converter(autoApply = true)
public class DowntimeRiskConverter implements AttributeConverter<DowntimeRisk, Integer> {

@Override
public Integer convertToDatabaseColumn(DowntimeRisk obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public DowntimeRisk convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return DowntimeRisk.fromValue(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.Esotericism;

@Converter(autoApply = true)
public class EsotericismConverter implements AttributeConverter<Esotericism, Integer> {

@Override
public Integer convertToDatabaseColumn(Esotericism obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public Esotericism convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return Esotericism.fromValue(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.OpsImpact;

@Converter(autoApply = true)
public class OpsImpactConverter implements AttributeConverter<OpsImpact, Integer> {

@Override
public Integer convertToDatabaseColumn(OpsImpact obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public OpsImpact convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return OpsImpact.fromValue(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jlab.sim.persistence.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jlab.sim.persistence.enumeration.PastDowntimeRate;

@Converter(autoApply = true)
public class PastDowntimeRateConverter implements AttributeConverter<PastDowntimeRate, Integer> {

@Override
public Integer convertToDatabaseColumn(PastDowntimeRate obj) {
if (obj == null) {
return null;
}
return obj.getValue();
}

@Override
public PastDowntimeRate convertToEntityAttribute(Integer value) {
if (value == null) {
return null;
}
return PastDowntimeRate.fromValue(value);
}
}
90 changes: 89 additions & 1 deletion src/main/java/org/jlab/sim/persistence/entity/Software.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.io.Serializable;
import java.math.BigInteger;
import java.util.*;
import org.jlab.sim.persistence.enumeration.SoftwareType;
import org.jlab.sim.persistence.enumeration.*;
import org.jlab.smoothness.persistence.util.YnStringToBoolean;

@Entity
Expand Down Expand Up @@ -60,6 +60,38 @@ public class Software implements Serializable {
@Convert(converter = YnStringToBoolean.class)
private boolean archived;

@NotNull
@Column(name = "OPS_IMPACT", nullable = false)
private OpsImpact impact;

@NotNull
@Column(name = "DOWN_PROBABILITY", nullable = false, updatable = false)
private DowntimeProbability probability;

@NotNull
@Column(name = "DOWNTIME_RISK", nullable = false, updatable = false)
private DowntimeRisk risk;

@NotNull
@Column(name = "PAST_DOWNTIME", nullable = false)
private PastDowntimeRate rate;

@NotNull
@Column(name = "DEBUGGABILITY_N_TESTING", nullable = false)
private DebugTestDifficulty difficulty;

@NotNull
@Column(name = "CODE_COMPLEXITY", nullable = false)
private CodeComplexity complexity;

@NotNull
@Column(name = "DOCUMENTATION_GAPS", nullable = false)
private DocumentationGaps gaps;

@NotNull
@Column(name = "ESOTERICISM", nullable = false)
private Esotericism esotericism;

@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(
name = "SOFTWARE_ID",
Expand Down Expand Up @@ -201,6 +233,62 @@ public void setArchivedSynced(boolean archivedSynced) {
this.archivedSynced = archivedSynced;
}

public OpsImpact getImpact() {
return impact;
}

public void setImpact(OpsImpact impact) {
this.impact = impact;
}

public DowntimeProbability getProbability() {
return probability;
}

public DowntimeRisk getRisk() {
return risk;
}

public PastDowntimeRate getRate() {
return rate;
}

public void setRate(PastDowntimeRate rate) {
this.rate = rate;
}

public DebugTestDifficulty getDifficulty() {
return difficulty;
}

public void setDifficulty(DebugTestDifficulty difficulty) {
this.difficulty = difficulty;
}

public CodeComplexity getComplexity() {
return complexity;
}

public void setComplexity(CodeComplexity complexity) {
this.complexity = complexity;
}

public DocumentationGaps getGaps() {
return gaps;
}

public void setGaps(DocumentationGaps gaps) {
this.gaps = gaps;
}

public Esotericism getEsotericism() {
return esotericism;
}

public void setEsotericism(Esotericism esotericism) {
this.esotericism = esotericism;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof Software)) return false;
Expand Down
Loading