Skip to content

Commit

Permalink
System description (#11)
Browse files Browse the repository at this point in the history
Fixes #10
  • Loading branch information
slominskir authored Aug 26, 2024
1 parent 7a75b41 commit 70f77d3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 10 deletions.
2 changes: 2 additions & 0 deletions container/oracle/initdb.d/02_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ CREATE TABLE SRM_OWNER.SYSTEM_AUD
REV INTEGER NOT NULL ,
REVTYPE INTEGER NOT NULL ,
NAME VARCHAR2(128 CHAR) NOT NULL ,
DESCRIPTION VARCHAR2(2048 CHAR) NULL ,
CATEGORY_ID INTEGER NOT NULL ,
WEIGHT INTEGER NULL ,
CONSTRAINT SYSTEM_AUD_PK PRIMARY KEY (SYSTEM_ID,REV),
Expand Down Expand Up @@ -132,6 +133,7 @@ CREATE TABLE SRM_OWNER.SYSTEM
(
SYSTEM_ID INTEGER NOT NULL ,
NAME VARCHAR2(128 CHAR) NOT NULL ,
DESCRIPTION VARCHAR2(2048 CHAR) NULL ,
CATEGORY_ID INTEGER NOT NULL ,
WEIGHT INTEGER NULL ,
CONSTRAINT SYSTEM_PK PRIMARY KEY (SYSTEM_ID),
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/jlab/srm/business/session/SystemFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ public List<SystemEntity> gatherDescendents(Category category, BigInteger applic
}

@PermitAll
public void addNew(BigInteger parentId, String name) throws UserFriendlyException {
public void addNew(BigInteger parentId, String name, String description)
throws UserFriendlyException {
String username = checkAuthenticated();

if (parentId == null) {
Expand All @@ -305,6 +306,7 @@ public void addNew(BigInteger parentId, String name) throws UserFriendlyExceptio
SystemEntity s = new SystemEntity();
s.setCategory(parent);
s.setName(name);
s.setDescription(description);
s.setWeight(BigInteger.valueOf(1000));

create(s);
Expand Down Expand Up @@ -332,7 +334,7 @@ public void remove(BigInteger systemId) throws UserFriendlyException {
}

@PermitAll
public void edit(BigInteger systemId, BigInteger parentId, String name)
public void edit(BigInteger systemId, BigInteger parentId, String name, String description)
throws UserFriendlyException {
String username = checkAuthenticated();

Expand Down Expand Up @@ -362,5 +364,6 @@ public void edit(BigInteger systemId, BigInteger parentId, String name)

s.setCategory(parent);
s.setName(name);
s.setDescription(description);
}
}
11 changes: 11 additions & 0 deletions src/main/java/org/jlab/srm/persistence/entity/SystemEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class SystemEntity implements Serializable, Comparable<SystemEntity> {
@Column(nullable = false, length = 128)
private String name;

@Column(nullable = true, length = 2048)
private String description;

private BigInteger weight;

@JoinColumn(name = "CATEGORY_ID", referencedColumnName = "CATEGORY_ID", nullable = false)
Expand Down Expand Up @@ -84,6 +87,14 @@ public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public BigInteger getWeight() {
return weight;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
try {
BigInteger parentId = ParamConverter.convertBigInteger(request, "parentId");
String name = request.getParameter("name");
systemFacade.addNew(parentId, name);
String description = request.getParameter("description");
systemFacade.addNew(parentId, name, description);
} catch (EJBAccessException e) {
logger.log(Level.WARNING, "Not authorized", e);
errorReason = "Not authorized";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
BigInteger systemId = ParamConverter.convertBigInteger(request, "systemId");
BigInteger parentId = ParamConverter.convertBigInteger(request, "parentId");
String name = request.getParameter("name");
systemFacade.edit(systemId, parentId, name);
String description = request.getParameter("description");
systemFacade.edit(systemId, parentId, name, description);
} catch (EJBAccessException e) {
logger.log(Level.WARNING, "Not authorized", e);
errorReason = "Not authorized";
Expand Down
15 changes: 14 additions & 1 deletion src/main/webapp/WEB-INF/views/setup/category-tree.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
#open-edit-root-dialog-button {
float: right;
}
#node-description {
resize: none;
height: 100px;
width: 370px;
}
</style>
</jsp:attribute>
<jsp:attribute name="scripts">
Expand Down Expand Up @@ -136,7 +141,7 @@
<option value="">&nbsp;</option>
<c:forEach items="${systemList}" var="system">
<option value="${system.systemId}"${param.systemId eq system.systemId ? ' selected="selected"' : ''}
data-category="${system.category.name}"><c:out
data-category="${system.category.name}" data-description="${system.description}"><c:out
value="${system.name}"/></option>
</c:forEach>
</select>
Expand Down Expand Up @@ -169,6 +174,14 @@
<input type="text" maxlength="128" id="node-name" name="node-name"/>
</div>
</li>
<li>
<div class="li-key">
<label for="node-description">Description</label>
</div>
<div class="li-value">
<textarea maxlength="2048" id="node-description" name="node-description"></textarea>
</div>
</li>
</ul>
</fieldset>
<div class="dialog-button-panel">
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/WEB-INF/views/system-detail.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<div id="page">
<h1>System ${system.name}</h1>
<dl class="dialog-content">
<dt>Description:</dt>
<dd>
<c:out value="${system.description eq null ? 'None' : system.description}"/>
</dd>
<dt>Group Responsibilities:</dt>
<dd>
<c:if test="${fn:length(system.groupResponsibilityList) > 0}">
Expand Down
21 changes: 16 additions & 5 deletions src/main/webapp/resources/js/category-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ jlab.srm.addSystem = function () {
$("#SaveButton").attr("disabled", "disabled");

var parentId = $("#category-parent").val(),
name = $("#node-name").val();
name = $("#node-name").val(),
description = $("#node-description").val();

var leaveSpinning = false;

Expand All @@ -220,7 +221,8 @@ jlab.srm.addSystem = function () {
type: "POST",
data: {
parentId: parentId,
name: name
name: name,
description: description
},
dataType: "html"
});
Expand Down Expand Up @@ -274,7 +276,8 @@ jlab.srm.editSystem = function () {
$("#SaveButton").attr("disabled", "disabled");

var parentId = $("#category-parent").val(),
name = $("#node-name").val();
name = $("#node-name").val(),
description = $("#node-description").val();

var leaveSpinning = false;

Expand All @@ -284,7 +287,8 @@ jlab.srm.editSystem = function () {
data: {
systemId: systemId,
parentId: parentId,
name: name
name: name,
description: description
},
dataType: "html"
});
Expand Down Expand Up @@ -454,6 +458,7 @@ $(document).on("click", "#open-add-category-dialog-button", function () {
$("#node-dialog").dialog("option", "title", "Add Category");
$("#select-node-fieldset").hide();
$("#new-value-fieldset").show();
$("#node-description").prop("disabled", true);
jlab.srm.clearAndOpenNodeDialog();
});

Expand All @@ -463,6 +468,7 @@ $(document).on("click", "#open-edit-category-dialog-button", function () {
$("#category-node-select").show();
$("#system-node-select").hide();
$("#new-value-fieldset").show();
$("#node-description").prop("disabled", true);
jlab.srm.clearAndOpenNodeDialog();
});

Expand All @@ -479,6 +485,7 @@ $(document).on("click", "#open-add-system-dialog-button", function () {
$("#node-dialog").dialog("option", "title", "Add System");
$("#select-node-fieldset").hide();
$("#new-value-fieldset").show();
$("#node-description").prop("disabled", false);
jlab.srm.clearAndOpenNodeDialog();
});

Expand All @@ -488,6 +495,7 @@ $(document).on("click", "#open-edit-system-dialog-button", function () {
$("#category-node-select").hide();
$("#system-node-select").show();
$("#new-value-fieldset").show();
$("#node-description").prop("disabled", false);
jlab.srm.clearAndOpenNodeDialog();
});

Expand Down Expand Up @@ -521,6 +529,7 @@ $(document).on("change", "#system", function () {
return $(this).text().trim() === currentParentCategoryName;
}).prop("selected", true);
$("#node-name").val($("#system option:selected").text().trim());
$("#node-description").val($("#system option:selected").attr("data-description"));
});

$(document).on("click", "#open-edit-root-dialog-button", function () {
Expand All @@ -536,7 +545,9 @@ $(function () {
$(".dialog").dialog({
autoOpen: false,
width: 600,
height: 400,
height: 500,
minHeight: 500,
minWidth: 600,
modal: true
});

Expand Down

0 comments on commit 70f77d3

Please sign in to comment.