Skip to content

Commit

Permalink
fixed code to load knowldge fragment; removed code support access to …
Browse files Browse the repository at this point in the history
…labkey (that was already broken)
  • Loading branch information
paulopinheiro1234 committed Jun 19, 2020
1 parent 096b411 commit 1930a77
Show file tree
Hide file tree
Showing 97 changed files with 72 additions and 3,497 deletions.
2 changes: 0 additions & 2 deletions app/org/hadatac/console/controllers/AuthApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ public Result doSignup() {
}

public Result doSignout() {
session().remove("LabKeyUserName");
session().remove("LabKeyPassword");
return this.authenticate.logout();
}
}
2 changes: 1 addition & 1 deletion app/org/hadatac/console/controllers/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class Version extends Controller {

public Result index() {
String code_version = "1.2.2";
String code_version = "1.2.3";
String base_ontology = ConfigFactory.load().getString("hadatac.community.ont_prefix");
String loaded_base_ontology = NameSpaces.getInstance().getNameByAbbreviation(base_ontology);
String loaded_base_ontology_version = Ontology.getVersionFromAbbreviation(base_ontology);
Expand Down
33 changes: 0 additions & 33 deletions app/org/hadatac/console/controllers/annotator/AutoAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpStatus;

import org.hadatac.entity.pojo.Credential;
import org.hadatac.console.controllers.AuthApplication;
import org.hadatac.console.controllers.annotator.routes;
import org.hadatac.console.http.ResumableUpload;
import org.hadatac.console.models.AssignOptionForm;
import org.hadatac.console.models.LabKeyLoginForm;
import org.hadatac.console.models.SysUser;
import org.hadatac.console.views.html.annotator.*;
import org.hadatac.console.views.html.triplestore.*;
Expand All @@ -41,15 +39,13 @@
import org.hadatac.entity.pojo.STR;
import org.hadatac.entity.pojo.ObjectCollection;
import org.hadatac.entity.pojo.User;
import org.hadatac.metadata.loader.LabkeyDataHandler;
import org.hadatac.metadata.loader.URIUtils;
import org.hadatac.utils.ConfigProp;
import org.hadatac.utils.Feedback;
import org.hadatac.utils.FileManager;
import org.hadatac.utils.NameSpace;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.labkey.remoteapi.CommandException;

import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.typesafe.config.ConfigException.Null;
Expand Down Expand Up @@ -293,35 +289,6 @@ public Result postDownloadTemplates(String dir) {
return postDownloadTemplates(dir);
}

@Restrict(@Group(AuthApplication.DATA_MANAGER_ROLE))
public Result setLabKeyCredentials() {
return ok(syncLabkey.render("init", routes.AutoAnnotator.
postSetLabKeyCredentials().url(), ""));
}

@Restrict(@Group(AuthApplication.DATA_MANAGER_ROLE))
public Result postSetLabKeyCredentials() {
Form<LabKeyLoginForm> form = formFactory.form(LabKeyLoginForm.class).bindFromRequest();
String user_name = form.get().getUserName();
String password = form.get().getPassword();
LabkeyDataHandler loader = new LabkeyDataHandler(
ConfigProp.getLabKeySite(), "/", user_name, password);
try {
loader.checkAuthentication();
Credential cred = new Credential();
cred.setUserName(user_name);
cred.setPassword(password);
cred.save();
} catch(CommandException e) {
if("Unauthorized".equals(e.getMessage())){
return ok(syncLabkey.render("login_failed", "", ""));
}
}

return ok(main.render("Results", "",
new Html("<h3>Your provided credentials are valid and saved!</h3>")));
}

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result checkAnnotationLog(String dir, String fileId) {
DataFile dataFile = DataFile.findById(fileId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public Result create(String dir, String fileId, String da_uri) {

// OR create a new DA if the file is not associated with any existing DA

if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null && session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.PrepareIngestion.create(dir, fileId, da_uri).url()));
}

String da_label = "";
String new_da_uri = "";

Expand All @@ -96,9 +91,6 @@ public Result create(String dir, String fileId, String da_uri) {
}

da.saveToSolr();
if (ConfigProp.getLabKeyLoginRequired()) {
da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

dataFile.setDataAcquisitionUri(da.getUri());
dataFile.save();
Expand Down Expand Up @@ -145,10 +137,6 @@ public Result postRefine(String dir, String fileId, String da_uri, String messag

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result selectStudy(String dir, String fileId, String da_uri) {
if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null && session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.PrepareIngestion.selectStudy(dir, fileId, da_uri).url()));
}

List<Study> studies = Study.find();

Expand All @@ -157,10 +145,6 @@ public Result selectStudy(String dir, String fileId, String da_uri) {

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result selectScope(String dir, String fileId, String da_uri, String std_uri) {
if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null && session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.PrepareIngestion.selectScope(dir, fileId, da_uri, std_uri).url()));
}

String[] fields = null;
String rowScope = null;
Expand Down Expand Up @@ -248,9 +232,6 @@ public Result processSelectStudy(String dir, String fileId, String da_uri) {
da.setStudyUri(std_uri);

da.saveToSolr();
if (ConfigProp.getLabKeyLoginRequired()) {
da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

return ok(prepareIngestion.render(dir, fileId, da, "Updated Stream Specification with deployment information"));
}
Expand Down Expand Up @@ -290,9 +271,6 @@ public Result processSelectScope(String dir, String fileId, String da_uri) {
da.setCellScopeUri(cellScopeUriList);

da.saveToSolr();
if (ConfigProp.getLabKeyLoginRequired()) {
da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

return ok(prepareIngestion.render(dir, fileId, da, "Updated Stream Specification with scope information"));
}
Expand Down Expand Up @@ -322,9 +300,6 @@ public Result processSelectDeployment(String dir, String fileId, String da_uri)
da.setDeploymentUri(dep_uri);

da.saveToSolr();
if (ConfigProp.getLabKeyLoginRequired()) {
da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

return ok(prepareIngestion.render(dir, fileId, da, "Updated Stream Specification with deployment information"));
}
Expand Down Expand Up @@ -358,9 +333,6 @@ public Result processSelectSchema(String dir, String fileId, String da_uri) {
da.setSchemaUri(das_uri);

da.saveToSolr();
if (ConfigProp.getLabKeyLoginRequired()) {
da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

return ok(prepareIngestion.render(dir, fileId, da, "Updated Stream Specification with data acquisition schema information"));
}
Expand Down Expand Up @@ -406,9 +378,6 @@ public Result removeAssociation(String dir, String fileId, String da_uri, String
}

da.saveToSolr();
if (ConfigProp.getLabKeyLoginRequired()) {
da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

message = "Association with " + daComponent + " removed from the Stream Specification.";
return ok(prepareIngestion.render(dir, fileId, da, message));
Expand All @@ -426,9 +395,6 @@ public Result completeDataAcquisition(String dir, String fileId, String da_uri)
da.setStatus(9999);

da.saveToSolr();
if (ConfigProp.getLabKeyLoginRequired()) {
da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

message = "Stream Specification set as complete";
return ok(prepareIngestion.render(dir, fileId, da, message));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ public Result postIndex(int stateId) {

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result newDataAcquisition() {
if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null
&& session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB
.logInLabkey(routes.DataAcquisitionManagement.newDataAcquisition().url()));
}

final SysUser sysUser = AuthApplication.getLocalUser(session());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public class DataAcquisitionScope extends Controller {

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result create(String dir, String fileId, String da_uri) {
if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null && session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.DataAcquisitionScope.create(dir, fileId, da_uri).url()));
}

STR da = null;
String ownerEmail = AuthApplication.getLocalUser(session()).getEmail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.hadatac.utils.ConfigProp;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.labkey.remoteapi.CommandException;

import be.objectify.deadbolt.java.actions.Group;
import be.objectify.deadbolt.java.actions.Restrict;
Expand All @@ -41,12 +40,6 @@ public class EditDataAcquisition extends Controller {

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result index(String dir, String filename, String uri, boolean bChangeParam) {
if (ConfigProp.getLabKeyLoginRequired() &&
(session().get("LabKeyUserName") == null || session().get("LabKeyPassword") == null)
&& bChangeParam) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.EditDataAcquisition.index(dir, filename, uri, bChangeParam).url()));
}

final SysUser sysUser = AuthApplication.getLocalUser(session());
try {
Expand Down Expand Up @@ -129,13 +122,9 @@ public Result processForm(String dir, String filename, String acquisitionUri, bo
}

da.saveToSolr();
int nRowsAffected = 0;
if (ConfigProp.getLabKeyLoginRequired()) {
nRowsAffected = da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}

return ok(main.render("Results,", "", new Html("<h3>"
+ String.format("%d row(s) have been inserted in Table \"DataAcquisition\"", nRowsAffected)
+ String.format("Content have been inserted in Table \"DataAcquisition\"")
+ "</h3>")));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.hadatac.entity.pojo.User;
import org.hadatac.utils.ConfigProp;
import org.hadatac.utils.Feedback;
import org.labkey.remoteapi.assay.Run;

import be.objectify.deadbolt.java.actions.Group;
import be.objectify.deadbolt.java.actions.Restrict;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ public Result processForm() {
// insert the new indicator content inside of the triplestore
ind.save();

// update/create new indicator in LabKey
if (ConfigProp.getLabKeyLoginRequired()) {
int nRowsAffected = ind.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
if (nRowsAffected <= 0) {
return badRequest("Failed to insert new indicator to LabKey!\n");
}
}

return ok(newFunctionConfirm.render(ind));
}
}
29 changes: 4 additions & 25 deletions app/org/hadatac/console/controllers/deployments/NewDeployment.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.hadatac.entity.pojo.TriggeringEvent;
import org.hadatac.metadata.loader.URIUtils;
import org.hadatac.utils.ConfigProp;
import org.labkey.remoteapi.CommandException;

import be.objectify.deadbolt.java.actions.Group;
import be.objectify.deadbolt.java.actions.Restrict;
Expand Down Expand Up @@ -57,10 +56,6 @@ public static SparqlQueryResults getQueryResults(String tabName) {

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result index(String type, String dir, String filename, String da_uri, Integer page) {
if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null && session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.NewDeployment.index(type, dir, filename, da_uri, page).url()));
}

if (type.equalsIgnoreCase("regular")) {
return ok(newDeployment.render(
Expand Down Expand Up @@ -137,16 +132,8 @@ public Result processForm(String dir, String filename, String da_uri, Integer pa
}
System.out.println("NewDeployment: Loading existing DA : [" + da_uri + "]");
da.setDeploymentUri(deployment.getUri());
String user_name = session().get("LabKeyUserName");
String password = session().get("LabKeyPassword");
if (user_name != null && password != null) {
if (ConfigProp.getLabKeyLoginRequired()) {
nRowsOfDeployment = deployment.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
nRowsOfDA = da.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}
deployment.saveToTripleStore();
da.save();
}
deployment.saveToTripleStore();
da.save();
} else {
/*
*
Expand All @@ -173,16 +160,8 @@ public Result processForm(String dir, String filename, String da_uri, Integer pa
param, UserManagement.getUriByEmail(user.getEmail()));

System.out.println("NewDeployment: Showing DA: " + dataAcquisition);
String user_name = session().get("LabKeyUserName");
String password = session().get("LabKeyPassword");
if (user_name != null && password != null) {
if (ConfigProp.getLabKeyLoginRequired()) {
nRowsOfDeployment = deployment.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
nRowsOfDA = dataAcquisition.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
}
deployment.saveToTripleStore();
dataAcquisition.save();
}
deployment.saveToTripleStore();
dataAcquisition.save();
}

return ok(deploymentConfirm.render("New Deployment created.", data, dir, filename, da_uri, page));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.hadatac.entity.pojo.UserGroup;
import org.hadatac.utils.ConfigProp;
import org.hadatac.utils.Feedback;
import org.labkey.remoteapi.assay.Run;

import be.objectify.deadbolt.java.actions.Group;
import be.objectify.deadbolt.java.actions.Restrict;
Expand Down
11 changes: 0 additions & 11 deletions app/org/hadatac/console/controllers/indicators/EditIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public class EditIndicator extends Controller {

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result index(String ind_uri) {
if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null && session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.EditIndicator.index(ind_uri).url()));
}

Indicator indicator = null;

Expand Down Expand Up @@ -111,13 +107,6 @@ public Result processForm(String ind_uri) {
// insert the new Indicator content inside of the triplestore regardless of any change -- the previous content has already been deleted
oldIndicator.save();

// update/create new Indicator in LabKey
if (ConfigProp.getLabKeyLoginRequired()) {
int nRowsAffected = oldIndicator.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
if (nRowsAffected <= 0) {
return badRequest("Failed to insert edited Indicator to LabKey!\n");
}
}

return ok(indicatorConfirm.render("Edit Indicator", oldIndicator));
}
Expand Down
12 changes: 0 additions & 12 deletions app/org/hadatac/console/controllers/indicators/NewIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public class NewIndicator extends Controller {

@Restrict(@Group(AuthApplication.DATA_OWNER_ROLE))
public Result index() {
if (ConfigProp.getLabKeyLoginRequired() && session().get("LabKeyUserName") == null && session().get("LabKeyPassword") == null) {
return redirect(org.hadatac.console.controllers.triplestore.routes.LoadKB.logInLabkey(
routes.NewIndicator.index().url()));
}
// may need addressing
Indicator indicator = new Indicator();

Expand Down Expand Up @@ -69,14 +65,6 @@ public Result processForm() {
// insert the new indicator content inside of the triplestore
ind.save();

// update/create new indicator in LabKey
if (ConfigProp.getLabKeyLoginRequired()) {
int nRowsAffected = ind.saveToLabKey(session().get("LabKeyUserName"), session().get("LabKeyPassword"));
if (nRowsAffected <= 0) {
return badRequest("Failed to insert new indicator to LabKey!\n");
}
}

return ok(newIndicatorConfirm.render(ind));
}
}
Loading

0 comments on commit 1930a77

Please sign in to comment.