Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
dkapoor committed Mar 16, 2018
2 parents 5b8477d + 78fe72d commit 0c97d12
Show file tree
Hide file tree
Showing 35 changed files with 458 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private UpdateContainer deleteLink(Alignment alignment, OntologyManager ontMgr,
LabeledLink delLink = alignment.getLinkById(linkId);
if(delLink != null) {
this.displayLabel = delLink.getLabel().getDisplayName();
} else {
this.displayLabel = edgeUri;
}

alignment.removeLink(linkId);
Expand Down
4 changes: 2 additions & 2 deletions karma-commands/commands-bloom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<artifactId>commands-bloom</artifactId>
<properties>
<hadoop.version>2.4.0.2.1.3.0-563</hadoop.version>
<hadoop.version>2.9.0</hadoop.version>
</properties>

<repositories>
Expand Down Expand Up @@ -102,4 +102,4 @@
</dependency>
</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class WorksheetHeadersUpdate extends AbstractUpdate {
private enum JsonKeys {
worksheetId, columns, columnName, characterLength, hasNestedTable,
columnClass, hNodeId, pythonTransformation, previousCommandId,
columnDerivedFrom, hNodeType, status, onError
columnDerivedFrom, hNodeType, status, onError, selectionPyCode
}

public WorksheetHeadersUpdate(String worksheetId, SuperSelection selection) {
Expand Down Expand Up @@ -101,7 +101,10 @@ private JSONObject getColumnJsonObject(VHNode hNode, ColumnMetadata colMeta) thr
if (t.hasNestedTable()) {
Selection sel = selection.getSelection(t.getNestedTable().getId());
if (sel != null)
{
hNodeObj.put(JsonKeys.status.name(), sel.getStatus().name());
hNodeObj.put(JsonKeys.selectionPyCode.name(), colMeta.getSelectionPythonCode(t.getNestedTable().getId()));
}
}
hNodeObj.put(JsonKeys.hNodeType.name(), t.getHNodeType().name());
Integer colLength = colMeta.getColumnPreferredLength(hNode.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package edu.isi.karma.controller.command.transformation;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;

import edu.isi.karma.controller.command.Command;
import edu.isi.karma.controller.command.ICommand;
import edu.isi.karma.controller.command.worksheet.AddColumnCommand;
import edu.isi.karma.controller.history.CommandConsolidator;
import edu.isi.karma.controller.history.HistoryJsonUtil;
import edu.isi.karma.rep.Workspace;

public class AddColumnConsolidator extends CommandConsolidator {

@Override
public Pair<ICommand, Object> consolidateCommand(List<ICommand> commands,
ICommand newCommand, Workspace workspace) {
if (newCommand instanceof SubmitPythonTransformationCommand) {
String model = newCommand.getModel();

Iterator<ICommand> itr = commands.iterator();
while(itr.hasNext()) {
ICommand tmp = itr.next();
if (((Command)tmp).getOutputColumns().equals(((Command)newCommand).getOutputColumns())
&& tmp.getModel().equals(model)
&& (tmp instanceof AddColumnCommand)) {
SubmitPythonTransformationCommand py = ((SubmitPythonTransformationCommand)newCommand);
JSONArray inputJSON = new JSONArray(py.getInputParameterJson());

JSONArray tmpInputJSON = new JSONArray(tmp.getInputParameterJson());
String hNodeId = HistoryJsonUtil.getStringValue("hNodeId", tmpInputJSON);

HistoryJsonUtil.setArgumentValue("hNodeId", hNodeId, inputJSON);
py.setInputParameterJson(inputJSON.toString());

return new ImmutablePair<>(tmp, (Object)py);
}
}
}
return null;
}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package edu.isi.karma.controller.command.transformation;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;

import edu.isi.karma.controller.command.Command;
import edu.isi.karma.controller.command.CommandException;
import edu.isi.karma.controller.command.ICommand;
import edu.isi.karma.controller.history.CommandConsolidator;
import edu.isi.karma.controller.history.HistoryJsonUtil;
import edu.isi.karma.controller.history.WorksheetCommandHistoryExecutor;
import edu.isi.karma.rep.Workspace;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class PyTransformConsolidator extends CommandConsolidator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ protected void generateTransformedValues(Workspace workspace,
repo.initializeInterpreter(interpreter);
Collection<Node> nodes = new ArrayList<>(Math.max(1000, worksheet
.getDataTable().getNumRows()));
worksheet.getDataTable().collectNodes(hNode.getHNodePath(f), nodes, selection);
SuperSelection tmpSelection = new SuperSelection("TEMP_SUPER_SELECTION");
worksheet.getDataTable().collectNodes(hNode.getHNodePath(f), nodes, tmpSelection);

Map<String, String> rowToValueMap = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public SubmitPythonTransformationCommand(String id, String model, String newColu
//logger.info("SubmitPythonTranformationCommand:" + id + " newColumnName:" + newColumnName + ", code=" + transformationCode);
this.pythonNodeId = hNodeId;
}

@Override
public String getCommandName() {
return this.getClass().getSimpleName();
Expand Down Expand Up @@ -124,6 +124,7 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
Map<String, String> mapping = gatherTransformedResults(workspace, nodeId);
handleJSONOutput(workspace, mapping, newColumnNameHNode);
}
newColumnAbsoluteName = newColumnNameHNode.getAbsoluteColumnName(f);
WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
return c;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {

c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet), workspace.getContextId()));
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
inputColumns.add(hNodeId);
outputColumns.add(newHNodeId);
newColumnAbsoluteName = ndid.getAbsoluteColumnName(workspace.getFactory());
return c;
Expand Down Expand Up @@ -194,10 +193,7 @@ public UpdateContainer undoIt(Workspace workspace) {
return WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet), workspace.getContextId());
}


public String getNewHNodeId() {
return newHNodeId;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
}
}

worksheet.getMetadataContainer().getColumnMetadata().removeSelectionPythonCode(hTable.getId());
WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
if(!this.isExecutedInBatch()) {
UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, superSel, workspace.getContextId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import edu.isi.karma.controller.command.CommandException;
import edu.isi.karma.controller.command.CommandType;
import edu.isi.karma.controller.command.WorksheetSelectionCommand;
import edu.isi.karma.controller.command.selection.LargeSelection;
import edu.isi.karma.controller.command.selection.LargeSelection.Operation;
import edu.isi.karma.controller.command.selection.MiniSelection;
import edu.isi.karma.controller.command.selection.Selection;
import edu.isi.karma.controller.command.selection.SelectionManager;
import edu.isi.karma.controller.command.selection.SuperSelection;
import edu.isi.karma.controller.update.ErrorUpdate;
import edu.isi.karma.controller.update.UpdateContainer;
Expand Down Expand Up @@ -65,28 +62,18 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
RepFactory factory = workspace.getFactory();
SuperSelection superSel = this.getSuperSelection(worksheet);
HTable hTable = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
Selection currentSel = superSel.getSelection(hTable.getId());
Selection anotherSel = null;
if (!operation.equalsIgnoreCase(Operation.Invert.name())) {
anotherSel = new MiniSelection(workspace, worksheetId, hTable.getId(), factory.getNewId("SEL"), superSel.getName(), pythonCode, onError);
worksheet.getSelectionManager().addSelection(anotherSel);
}
if (currentSel == null && operation.equalsIgnoreCase(Operation.Invert.name()) ) {
return getErrorUpdate("No defined Selection");
}
if (currentSel == null) {
currentSel = new MiniSelection(workspace, worksheetId, hTable.getId(), factory.getNewId("SEL"), superSel.getName(), SelectionManager.defaultCode, onError);
worksheet.getSelectionManager().addSelection(currentSel);
}

anotherSel = new MiniSelection(workspace, worksheetId, hTable.getId(), factory.getNewId("SEL"), superSel.getName(), pythonCode, onError);
worksheet.getSelectionManager().addSelection(anotherSel);
worksheet.getMetadataContainer().getColumnMetadata().addSelectionPythonCode(hTable.getId(), this.pythonCode);

try {
Operation operation = Operation.valueOf(Operation.class, this.operation);
Selection t = new LargeSelection(workspace, worksheetId, hTable.getId(), factory.getNewId("SEL"), superSel.getName(), currentSel, anotherSel, operation);
worksheet.getSelectionManager().addSelection(t);
outputColumns.addAll(t.getInputColumns());
previousSelection = superSel.getSelection(t.getHTableId());
outputColumns.addAll(anotherSel.getInputColumns());
previousSelection = superSel.getSelection(hTable.getId());
if (previousSelection != null)
superSel.removeSelection(previousSelection);
superSel.addSelection(t);
superSel.addSelection(anotherSel);

}catch (Exception e) {
return getErrorUpdate("The operation is undefined");
Expand All @@ -104,6 +91,7 @@ public UpdateContainer doIt(Workspace workspace) throws CommandException {
public UpdateContainer undoIt(Workspace workspace) {
inputColumns.clear();
outputColumns.clear();
RepFactory factory = workspace.getFactory();
Worksheet worksheet = workspace.getWorksheet(worksheetId);
SuperSelection superSel = getSuperSelection(worksheet);
HNode hNode = workspace.getFactory().getHNode(hNodeId);
Expand All @@ -116,6 +104,8 @@ public UpdateContainer undoIt(Workspace workspace) {
worksheet.getSelectionManager().removeSelection(currentSel);
superSel.removeSelection(currentSel);
}
worksheet.getMetadataContainer().getColumnMetadata().removeSelectionPythonCode(factory.getHTable(factory.getHNode(hNodeId).getHTableId()).getId());

WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, superSel, workspace.getContextId());
uc.add(new WorksheetSuperSelectionListUpdate(worksheetId));
Expand Down
Loading

0 comments on commit 0c97d12

Please sign in to comment.