Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
dkapoor committed Aug 18, 2014
2 parents 5173bed + 98f8a3e commit df3114b
Show file tree
Hide file tree
Showing 352 changed files with 16,617 additions and 13,506 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ Thumbs.db


*.log

*.avro
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@
import edu.isi.karma.controller.history.WorksheetCommandHistoryExecutor;
import edu.isi.karma.controller.update.AbstractUpdate;
import edu.isi.karma.controller.update.ErrorUpdate;
import edu.isi.karma.controller.update.HistoryAddCommandUpdate;
import edu.isi.karma.controller.update.InfoUpdate;
import edu.isi.karma.controller.update.UpdateContainer;
import edu.isi.karma.controller.update.WorksheetListUpdate;
import edu.isi.karma.controller.update.WorksheetUpdateFactory;
import edu.isi.karma.kr2rml.KR2RMLVersion;
import edu.isi.karma.kr2rml.mapping.KR2RMLMapping;
import edu.isi.karma.kr2rml.mapping.R2RMLMappingIdentifier;
Expand All @@ -62,7 +61,8 @@ public class ApplyHistoryFromR2RMLModelCommand extends WorksheetCommand {
private boolean override;
private static Logger logger = LoggerFactory.getLogger(ApplyHistoryFromR2RMLModelCommand.class);

protected ApplyHistoryFromR2RMLModelCommand(String id, File uploadedFile, String worksheetId, boolean override) {
protected ApplyHistoryFromR2RMLModelCommand(String id, File uploadedFile,
String worksheetId, boolean override) {
super(id, worksheetId);
this.r2rmlModelFile = uploadedFile;
this.override = override;
Expand Down Expand Up @@ -96,13 +96,7 @@ public CommandType getCommandType() {
public UpdateContainer doIt(Workspace workspace) throws CommandException {
final Worksheet worksheet = workspace.getWorksheet(worksheetId);
UpdateContainer c = new UpdateContainer();
c.add(new WorksheetListUpdate());
UpdateContainer rwu = WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId);
if(rwu != null)
{
c.append(rwu);
}


try {
JSONArray historyJson = extractHistoryFromModel(workspace, c);
HistoryJSONEditor editor = new HistoryJSONEditor(new JSONArray(historyJson.toString()), workspace, worksheetId);
Expand All @@ -126,23 +120,17 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
}
System.out.println(editor.getHistoryJSON().toString(4));
UpdateContainer hc = histExecutor.executeAllCommands(historyJson);
if(hc != null)
if(hc != null) {
hc.removeUpdateByClass(HistoryAddCommandUpdate.class);
hc.removeUpdateByClass(InfoUpdate.class);
hc.removeUpdateByClass(ErrorUpdate.class);
c.append(hc);
}
} catch (Exception e) {
String msg = "Error occured while applying history!";
logger.error(msg, e);
return new UpdateContainer(new ErrorUpdate(msg));
}

// Add worksheet updates that could have resulted out of the transformation commands
for (Worksheet newws : workspace.getWorksheets()) {
if (newws.getId().compareTo(worksheetId) != 0) {
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(newws.getId()));
Alignment alignment = AlignmentManager.Instance().getAlignmentOrCreateIt(workspace.getId(), newws.getId(), workspace.getOntologyManager());
c.append(WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(newws.getId(), workspace, alignment));
}
}
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
c.add(new InfoUpdate("Model successfully applied!"));
c.add(new AbstractUpdate() {

Expand All @@ -169,6 +157,7 @@ public void generateJson(String prefix, PrintWriter pw,
}

});

return c;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import edu.isi.karma.controller.command.CommandException;
import edu.isi.karma.controller.command.CommandType;
import edu.isi.karma.controller.command.ICommand.CommandTag;
import edu.isi.karma.controller.command.WorksheetCommand;
import edu.isi.karma.controller.update.UpdateContainer;
import edu.isi.karma.controller.update.WorksheetUpdateFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class AddUserLinkToAlignmentCommand extends WorksheetCommand {

public AddUserLinkToAlignmentCommand(String id, String edgeId,
String alignmentId, String worksheetId) {

super(id, worksheetId);
this.edgeId = edgeId;
this.alignmentId = alignmentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
******************************************************************************/
package edu.isi.karma.controller.command.alignment;

import javax.servlet.http.HttpServletRequest;

import org.json.JSONArray;
import org.json.JSONException;

import edu.isi.karma.controller.command.Command;
import edu.isi.karma.controller.command.JSONInputCommandFactory;
import edu.isi.karma.controller.history.HistoryJsonUtil;
import edu.isi.karma.modeling.alignment.AlignmentManager;
import edu.isi.karma.rep.Workspace;
import org.json.JSONArray;
import org.json.JSONException;

import javax.servlet.http.HttpServletRequest;

public class AddUserLinkToAlignmentCommandFactory extends JSONInputCommandFactory {
private enum Arguments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@

package edu.isi.karma.controller.command.alignment;

import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.isi.karma.controller.command.CommandException;
import edu.isi.karma.controller.command.CommandType;
import edu.isi.karma.controller.command.WorksheetCommand;
import edu.isi.karma.controller.command.selection.SuperSelectionManager;
import edu.isi.karma.controller.history.WorksheetCommandHistoryExecutor;
import edu.isi.karma.controller.update.ErrorUpdate;
import edu.isi.karma.controller.update.InfoUpdate;
import edu.isi.karma.controller.update.UpdateContainer;
import edu.isi.karma.controller.update.WorksheetUpdateFactory;
import edu.isi.karma.er.helper.TripleStoreUtil;
import edu.isi.karma.rep.Workspace;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApplyModelFromTripleStoreCommand extends WorksheetCommand {

Expand Down Expand Up @@ -115,7 +117,7 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
histExecutor.executeAllCommands(historyJson);

// Add worksheet updates that could have resulted out of the transformation commands
UpdateContainer c = WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId);
UpdateContainer c = WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, SuperSelectionManager.DEFAULT_SELECTION);
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
c.add(new InfoUpdate("Model successfully applied!"));
return c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

package edu.isi.karma.controller.command.alignment;

import javax.servlet.http.HttpServletRequest;

import edu.isi.karma.controller.command.Command;
import edu.isi.karma.controller.command.CommandFactory;
import edu.isi.karma.rep.Workspace;

import javax.servlet.http.HttpServletRequest;

public class ApplyModelFromTripleStoreCommandFactory extends CommandFactory {

private enum Arguments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import edu.isi.karma.controller.command.Command;
import edu.isi.karma.controller.command.CommandException;
import edu.isi.karma.controller.command.CommandType;
import edu.isi.karma.controller.command.WorksheetCommand;
import edu.isi.karma.controller.command.WorksheetSelectionCommand;
import edu.isi.karma.controller.command.selection.SuperSelection;
import edu.isi.karma.controller.command.worksheet.AddValuesCommand;
import edu.isi.karma.controller.command.worksheet.AddValuesCommandFactory;
import edu.isi.karma.controller.update.ErrorUpdate;
Expand Down Expand Up @@ -48,7 +49,7 @@
import edu.isi.karma.rep.metadata.WorksheetProperties.Property;
import edu.isi.karma.webserver.KarmaException;

public class AugmentDataCommand extends WorksheetCommand{
public class AugmentDataCommand extends WorksheetSelectionCommand{

private static Logger LOG = LoggerFactory.getLogger(AugmentDataCommand.class);
private String predicate;
Expand All @@ -62,8 +63,8 @@ public class AugmentDataCommand extends WorksheetCommand{
private String sameAsPredicate;
private final Integer limit = 200;
Stack<Command> appliedCommands;
public AugmentDataCommand(String id, String dataRepoUrl, String worksheetId, String columnUri, String predicate, String otherClass, String hNodeId, Boolean incoming, String sameAsPredicate) {
super(id, worksheetId);
public AugmentDataCommand(String id, String dataRepoUrl, String worksheetId, String columnUri, String predicate, String otherClass, String hNodeId, Boolean incoming, String sameAsPredicate, String selectionId) {
super(id, worksheetId, selectionId);
this.predicate = predicate;
this.columnUri = columnUri;
this.otherClass = otherClass;
Expand Down Expand Up @@ -111,10 +112,11 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
RepFactory factory = workspace.getFactory();
Worksheet worksheet = factory.getWorksheet(worksheetId);
SuperSelection selection = getSuperSelection(worksheet);
if (alignment.GetTreeRoot() != null)
hNodeId = FetchHNodeIdFromAlignmentCommand.gethNodeId(alignmentId, columnUri);
if (hNodeId == null) {
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId));
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
return c;
}
Expand All @@ -123,11 +125,11 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
hNodeIds.add(hNodeId);
inputColumns.addAll(hNodeIds);
List<Table> dataTables = new ArrayList<Table>();
CloneTableUtils.getDatatable(worksheet.getDataTable(), factory.getHTable(hnode.getHTableId()), dataTables);
CloneTableUtils.getDatatable(worksheet.getDataTable(), factory.getHTable(hnode.getHTableId()), dataTables, selection);
Map<String, String> rowHashToSubjectURI = new HashMap<String, String>();
Map<String, List<String>> SubjectURIToRowId = new HashMap<String, List<String>>();
for(Table t : dataTables) {
for(Row r : t.getRows(0, t.getNumRows())) {
for(Row r : t.getRows(0, t.getNumRows(), selection)) {
Node n = r.getNode(hNodeId);
if(n != null && n.getValue() != null && !n.getValue().isEmptyValue() && n.getValue().asString() != null && !n.getValue().asString().trim().isEmpty() ) {
String uri = n.getValue().asString().trim().replace(" ", "");
Expand Down Expand Up @@ -230,7 +232,7 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
try {
OntologyManager ontMgr = workspace.getOntologyManager();
Label label = ontMgr.getUriLabel(incoming ? otherClass : predicate);
AddValuesCommand command = (AddValuesCommand) addFactory.createCommand(input, workspace, hNodeId, worksheetId, hnode.getHTableId(), label.getDisplayName(), HNodeType.AugmentData);
AddValuesCommand command = (AddValuesCommand) addFactory.createCommand(input, workspace, hNodeId, worksheetId, hnode.getHTableId(), label.getDisplayName(), HNodeType.AugmentData, selection.getName());
command.doIt(workspace);
outputColumns.addAll(command.getOutputColumns());
isNewNode |= command.isNewNode();
Expand Down Expand Up @@ -272,7 +274,7 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {


semanticTypesArray.put(semanticType);
Command sstCommand = sstFactory.createCommand(workspace, worksheetId, nestedHNodeId, false, semanticTypesArray, false, "");
Command sstCommand = sstFactory.createCommand(workspace, worksheetId, nestedHNodeId, false, semanticTypesArray, false, "", selection.getName());
appliedCommands.push(sstCommand);
sstCommand.doIt(workspace);
if(!resultClass.get(i).trim().isEmpty())
Expand Down Expand Up @@ -302,16 +304,16 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
Command changeInternalNodeLinksCommand = cinlcf.createCommand(worksheetId, alignmentId, new JSONArray(), newEdges, workspace);
changeInternalNodeLinksCommand.doIt(workspace);
appliedCommands.push(changeInternalNodeLinksCommand);
Command setMetaDataCommand = smpcf.createCommand(workspace, nestedHNodeId, worksheetId, "isUriOfClass", targetId, "");
Command setMetaDataCommand = smpcf.createCommand(workspace, nestedHNodeId, worksheetId, "isUriOfClass", targetId, "", selection.getName());
setMetaDataCommand.doIt(workspace);
appliedCommands.push(setMetaDataCommand);
}
}

}


c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId));
WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
return c;
}
Expand All @@ -323,7 +325,7 @@ public UpdateContainer undoIt(Workspace workspace) {
Command command = appliedCommands.pop();
command.undoIt(workspace);
}
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId));
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
return c;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
public class AugmentDataCommandFactory extends JSONInputCommandFactory{

private enum Arguments {
worksheetId, predicate, triplesMap, alignmentId, columnUri, otherClass, tripleStoreUrl, hNodeId, incoming, sameAsPredicate
worksheetId, predicate, triplesMap,
alignmentId, columnUri, otherClass,
tripleStoreUrl, hNodeId, incoming,
sameAsPredicate, selectionName
}

@Override
Expand All @@ -27,7 +30,12 @@ public Command createCommand(HttpServletRequest request, Workspace workspace) {
String hNodeId = request.getParameter(Arguments.hNodeId.name());
String incoming = request.getParameter(Arguments.incoming.name());
String sameAsPredicate = request.getParameter(Arguments.sameAsPredicate.name());
return new AugmentDataCommand(getNewId(workspace), dataRepoUrl, worksheetId, columnUri, predicate, otherClass, hNodeId, Boolean.parseBoolean(incoming), sameAsPredicate);
String selectionName = request.getParameter(Arguments.selectionName.name());
return new AugmentDataCommand(getNewId(workspace), dataRepoUrl, worksheetId,
columnUri, predicate, otherClass,
hNodeId, Boolean.parseBoolean(incoming),
sameAsPredicate,
selectionName);
}

@Override
Expand All @@ -47,7 +55,13 @@ public Command createCommand(JSONArray inputJson, Workspace workspace)
String hNodeId = CommandInputJSONUtil.getStringValue(Arguments.hNodeId.name(), inputJson);
String incoming = CommandInputJSONUtil.getStringValue(Arguments.incoming.name(), inputJson);
String sameAsPredicate = CommandInputJSONUtil.getStringValue(Arguments.sameAsPredicate.name(), inputJson);
AugmentDataCommand cmd = new AugmentDataCommand(getNewId(workspace), dataRepoUrl, worksheetId, columnUri, predicate, otherClass, hNodeId, Boolean.parseBoolean(incoming),sameAsPredicate);
this.normalizeSelectionId(worksheetId, inputJson, workspace);
String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson);
AugmentDataCommand cmd = new AugmentDataCommand(getNewId(workspace), dataRepoUrl, worksheetId,
columnUri, predicate, otherClass, hNodeId,
Boolean.parseBoolean(incoming),
sameAsPredicate,
selectionName);

cmd.setInputParameterJson(inputJson.toString());
return cmd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@

import edu.isi.karma.controller.command.CommandException;
import edu.isi.karma.controller.command.CommandType;
import edu.isi.karma.controller.command.WorksheetCommand;
import edu.isi.karma.controller.command.WorksheetSelectionCommand;
import edu.isi.karma.controller.update.UpdateContainer;
import edu.isi.karma.controller.update.WorksheetUpdateFactory;
import edu.isi.karma.rep.Workspace;

public class AugmentDataDispachCommand extends WorksheetCommand {
public class AugmentDataDispachCommand extends WorksheetSelectionCommand {
private String predicateIncoming, predicateOutgoing;
private AugmentDataCommand incoming;
private AugmentDataCommand outgoing;
public AugmentDataDispachCommand(String id, String dataRepoUrl, String worksheetId, String columnUri, String predicateIncoming, String otherClassIncoming, String predicateOutgoing, String otherClassOutgoing, String hNodeId, String sameAsPredicate) {
super(id, worksheetId);
public AugmentDataDispachCommand(String id, String dataRepoUrl, String worksheetId,
String columnUri, String predicateIncoming, String otherClassIncoming,
String predicateOutgoing, String otherClassOutgoing,
String hNodeId, String sameAsPredicate, String selectionId) {
super(id, worksheetId, selectionId);
this.predicateIncoming = predicateIncoming;
this.predicateOutgoing = predicateOutgoing;
incoming = new AugmentDataCommand(id, dataRepoUrl, worksheetId, columnUri, predicateIncoming, otherClassIncoming, hNodeId, true, sameAsPredicate);
outgoing = new AugmentDataCommand(id, dataRepoUrl, worksheetId, columnUri, predicateOutgoing, otherClassOutgoing, hNodeId, false, sameAsPredicate);
incoming = new AugmentDataCommand(id, dataRepoUrl, worksheetId, columnUri, predicateIncoming, otherClassIncoming, hNodeId, true, sameAsPredicate, selectionId);
outgoing = new AugmentDataCommand(id, dataRepoUrl, worksheetId, columnUri, predicateOutgoing, otherClassOutgoing, hNodeId, false, sameAsPredicate, selectionId);
addTag(CommandTag.Transformation);
}

Expand Down Expand Up @@ -73,7 +76,7 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
incoming.doIt(workspace);
if (predicatesoutgoingarray.length() > 0)
outgoing.doIt(workspace);
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId));
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
return c;
}
Expand All @@ -87,7 +90,7 @@ public UpdateContainer undoIt(Workspace workspace) {
incoming.undoIt(workspace);
if (predicatesoutgoingarray.length() > 0)
outgoing.undoIt(workspace);
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId));
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
return c;
}
Expand Down
Loading

0 comments on commit df3114b

Please sign in to comment.