Skip to content

Commit

Permalink
ConDec-71: Improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
kleebaum committed Jun 28, 2018
1 parent e7204bd commit 3e47f8d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import de.uhd.ifi.se.decision.documentation.jira.persistence.ConfigPersistence;

/**
* @description Renders the administration page to change the plug-in configuration of a single project
* @description Renders the administration page to change the plug-in
* configuration of a single project
*/
public class SettingsOfSingleProject extends AbstractSettingsServlet {

Expand All @@ -29,18 +30,15 @@ public class SettingsOfSingleProject extends AbstractSettingsServlet {

@Inject
public SettingsOfSingleProject(@ComponentImport UserManager userManager,
@ComponentImport LoginUriProvider loginUriProvider, @ComponentImport TemplateRenderer renderer) {
@ComponentImport LoginUriProvider loginUriProvider, @ComponentImport TemplateRenderer renderer) {
super(userManager, loginUriProvider, renderer);
}

protected boolean isValidUser(HttpServletRequest request) {
String projectKey = request.getParameter("projectKey");

String username = userManager.getRemoteUsername(request);
if (isProjectAdmin(username, projectKey)) {
return true;
}
return false;
return isProjectAdmin(username, projectKey);
}

private boolean isProjectAdmin(String username, String projectKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public Object doInTransaction() {
return settings.get(pluginStorageKey + ".isIssueStrategy");
}
});
if (isIssueStrategy instanceof String && isIssueStrategy.equals("true")) {
return true;
}
return false;
return isIssueStrategy instanceof String && "true".equals(isIssueStrategy);
}

public static void setIssueStrategy(String projectKey, boolean isIssueStrategy) {
Expand All @@ -37,10 +34,7 @@ public Object doInTransaction() {
return settings.get(pluginStorageKey + ".isActivated");
}
});
if (isActivated instanceof String && isActivated.equals("true")) {
return true;
}
return false;
return isActivated instanceof String && "true".equals(isActivated);
}

public static void setActivated(String projectKey, boolean isActivated) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/js/controller/decdoc.rest.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function getLinkedDecisionComponents(id, callback) {
function getUnlinkedDecisionComponents(id, callback) {
getJSON(AJS.contextPath() + "/rest/decisions/latest/decisions/getUnlinkedDecisionComponents.json?projectKey="
+ getProjectKey() + "&id=" + id, function(error, unlinkedDecisionComponents) {
if (error == null) {
if (error === null) {
callback(unlinkedDecisionComponents);
} else {
showFlag("error",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/js/view/decdoc.accordion.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function showDetailsOfChildren(parentId) {
function showDetailsOfSingleChild(decisionKnowledgeElement) {
var type = decisionKnowledgeElement.type;
for (var i = 0; i < simpleKnowledgeTypes.length; i++) {
if (simpleKnowledgeTypes[i].toLocaleLowerCase() == type.toLocaleLowerCase()) {
if (simpleKnowledgeTypes[i].toLocaleLowerCase() === type.toLocaleLowerCase()) {
document.getElementById(simpleKnowledgeTypes[i]).insertAdjacentHTML(
'beforeend',
'<div class="issuelinkbox"><p>' + type + ' / ' + decisionKnowledgeElement.summary + '</p>'
Expand All @@ -87,7 +87,7 @@ function addOptionToAddDecisionComponent(type, id) {

function setUpEditorContentForAddingComponent(type) {
var radioButtons = "";
if (type == "Argument") {
if (type === "Argument") {
radioButtons = "<input type='radio' name='form-radio-argument' value='Pro Argument' checked='checked'>Pro"
+ "<input type='radio' name='form-radio-argument' value='Contra Argument'>Contra"
+ "<input type='radio' name='form-radio-argument' value='Comment'>Comment";
Expand Down
11 changes: 6 additions & 5 deletions src/main/resources/js/view/decdoc.context.menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function setUpModal() {
for (var counter = 0; counter < elementsWithCloseFunction.length; counter++) {
elementsWithCloseFunction[counter].onclick = function() {
closeModal();
}
};
}

// closes modal window if user clicks anywhere outside of the modal
Expand Down Expand Up @@ -112,7 +112,7 @@ var contextMenuLinkAction = {
var id = getSelectedTreantNodeId(options);
setUpContextMenuContentForLinkAction(id);
}
}
};

function setUpContextMenuContentForLinkAction(id) {
setUpModal();
Expand Down Expand Up @@ -155,7 +155,7 @@ var contextMenuEditAction = {
var id = getSelectedTreantNodeId(options);
setUpContextMenuContentForEditAction(id);
}
}
};

function setUpContextMenuContentForEditAction(id) {
isIssueStrategy(id, function(isIssueStrategy) {
Expand All @@ -173,6 +173,7 @@ function setUpContextMenuContentForEditAction(id) {
var description = decisionKnowledgeElement.description;
var type = decisionKnowledgeElement.type;
setUpContextMenuContent(summary, description, type, editKnowledgeElementText);

var submitButton = document.getElementById("form-input-submit");
submitButton.onclick = function() {
var summary = document.getElementById("form-input-summary").value;
Expand All @@ -198,7 +199,7 @@ var contextMenuDeleteAction = {
var id = getSelectedTreantNodeId(options);
setUpContextMenuContentForDeleteAction(id);
}
}
};

function setUpContextMenuContentForDeleteAction(id) {
setUpModal();
Expand Down Expand Up @@ -229,7 +230,7 @@ var contextMenuActions = {
"link" : contextMenuLinkAction,
"edit" : contextMenuEditAction,
"delete" : contextMenuDeleteAction
}
};

function closeModal() {
var modal = document.getElementById("ContextMenuModal");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/js/view/decdoc.treant.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function findOldParentNode(dragId) {
var nodes = treantTree.tree.nodeDB.db;
var i;
for (i = 0; i < nodes.length; i++) {
if (nodes[i].nodeHTMLid == dragId) {
if (nodes[i].nodeHTMLid === dragId) {
var parentElement = treantTree.tree.getNodeDb().get(nodes[i].parentId);
oldParentId = parentElement.nodeHTMLid;
}
Expand Down

0 comments on commit 3e47f8d

Please sign in to comment.