public void actionPerformed(ActionEvent e) { JComponent component = null; try { component = guiRenderer.getComponent(guiContext .getReferenceService(), guiReference); } catch (RendererException e1) {// maybe this should be // Exception // show the user that something unexpected has happened but // continue component = new JTextArea( "Could not render using renderer type " + guiRenderer.getClass().getName() + "\n" + "Please try with a different renderer if available and consult log for details of problem"); logger.warn("Couln not render using " + guiRenderer.getClass().getName(), e1); } // RenderedResultComponent rendererComponent = // RendererResultComponentFactory.getInstance().getRendererComponent(); // rendererComponent.setResultComponent(component); // renderedResultComponent.setResultComponent(component); }
@SuppressWarnings("unused") private InvocationContextImpl copyInvocationContext( final AsynchronousActivityCallback callback) { InvocationContext originalContext = callback.getContext(); ReferenceService rs = originalContext.getReferenceService(); InvocationContextImpl newContext = new InvocationContextImpl(rs, null); // for (Object o : originalContext.getEntities(Object.class)) { // newContext.addEntity(o); // } return newContext; }
/** * @param originalCallback * @param invocationContext * @param exceptionHandling2 */ public ProxyCallback(AsynchronousActivityCallback originalCallback, InvocationContext invocationContext, ExceptionHandling exceptionHandling2) { super(); this.originalCallback = originalCallback; this.exceptionHandling = exceptionHandling2; context = invocationContext; referenceService = context.getReferenceService(); listService = referenceService.getListService(); errorService = referenceService.getErrorDocumentService(); }
@Override public Map<String, Object> getInputData() { final Map<String, Object> inputData = new HashMap<String, Object>(); final InvocationContext context = this.callback.getContext(); final ReferenceService referenceService = context.getReferenceService(); for (final String inputName : this.inputs.keySet()) { final Object input = referenceService.renderIdentifier(this.inputs .get(inputName), this.getInputPort(inputName) .getTranslatedElementClass(), this.callback.getContext()); inputData.put(inputName, input); } return inputData; }
/** * Get all of the available renderers for a specific MIME type. If there is * a problem with one then catch the exception and log the problem but carry * on since there is probably more than one way to render the data * * @param context.getReferenceService() * @param entityIdentifier * @param mimeType * @return */ public List<Renderer> getRenderersForMimeType(InvocationContext context, T2Reference reference, String mimeType) { ArrayList<Renderer> list = new ArrayList<Renderer>(); for (Renderer renderer : getInstances()) { try { if (renderer.canHandle(context.getReferenceService(), reference, mimeType)) { list.add(renderer); } } catch (RendererException e) { logger.warn("Problem with renderer for " + renderer.getType(), e); } } return list; }
public static List<ErrorDocument> getErrorDocuments(T2Reference reference, InvocationContext context) { List<ErrorDocument> errorDocuments = new ArrayList<ErrorDocument>(); if (reference.getReferenceType().equals(T2ReferenceType.ErrorDocument)) { ErrorDocumentService errorDocumentService = context.getReferenceService().getErrorDocumentService(); errorDocuments.add(errorDocumentService.getError(reference)); } else if (reference.getReferenceType().equals(T2ReferenceType.IdentifiedList)) { ListService listService = context.getReferenceService().getListService(); IdentifiedList<T2Reference> list = listService.getList(reference); for (T2Reference listReference : list) { errorDocuments.addAll(getErrorDocuments(listReference, context)); } } return errorDocuments; }
@Override public void receiveResult(final Map<String, Object> resultMap) { if (this.answered) { return; } final Map<String, T2Reference> outputs = new HashMap<String, T2Reference>(); final InvocationContext context = this.callback.getContext(); final ReferenceService referenceService = context.getReferenceService(); for (final Object key : resultMap.keySet()) { final String keyString = (String) key; final Object value = resultMap.get(key); final Integer depth = this.findPortDepth(keyString); if (depth == null) { this.callback.fail("Data sent for unknown port : " + keyString); } outputs.put(keyString, referenceService.register(value, depth, true, context)); } this.callback.receiveResult(outputs, new int[0]); this.answered = true; }
public void resultTokenProduced(WorkflowDataToken dataToken, String portname) { if (dataToken.getIndex().length == 0) { T2Reference reference = dataToken.getData(); System.out.println("Output reference made = " + reference); Object value = reference; if (reference.containsErrors()) { System.out.println("Contains errors!"); printAllErrors(context.getReferenceService().resolveIdentifier( reference, null, context)); } else { try { value = context.getReferenceService().renderIdentifier( reference, Object.class, context); } catch (ReferenceServiceException ex) { ex.printStackTrace(); } } resultMap.put(portname, value); synchronized (this) { outputCount--; } } }
public void run() { ReferenceService referenceService = callback.getContext().getReferenceService(); try { T2Reference id = referenceService.register(value, 0, true, callback.getContext()); Map<String,T2Reference> outputData = new HashMap<String, T2Reference>(); outputData.put("value", id); callback.receiveResult(outputData, new int[0]); } catch (ReferenceServiceException e) { callback.fail(e.getMessage(),e); } }
Object dereference(String stringRef) { T2Reference ref = referenceFromString(stringRef); if ( ref != null ) { return getInvocationContext().getReferenceService().resolveIdentifier(ref, null, getInvocationContext()); } return null; }
protected Map<String, DummyEventHandler> addDummyEventHandlersToOutputs( Dataflow dataflow) throws EditException { Edits edits = new EditsImpl(); Map<String, DummyEventHandler> eventHandlers = new HashMap<String, DummyEventHandler>(); for (DataflowOutputPort outputPort : dataflow.getOutputPorts()) { DummyEventHandler testOutputEventHandler = new DummyEventHandler( context.getReferenceService()); eventHandlers.put(outputPort.getName(), testOutputEventHandler); Datalink link = edits.createDatalink(outputPort, testOutputEventHandler); edits.getConnectDatalinkEdit(link).doEdit(); } return eventHandlers; }
public void init(InvocationContext context) { for (ProvenanceConnectorFactory factory : provenanceConnectorFactories) { if (connectorType.equalsIgnoreCase(factory.getConnectorType())) { provenanceConnector = factory.getProvenanceConnector(); } } logger.info("Provenance being captured using: " + provenanceConnector); //slight change, the init is outside but it also means that the init call has to ensure that the dbURL //is set correctly provenanceConnector.init(); provenanceConnector.setReferenceService(context.getReferenceService()); // CHECK context.getReferenceService()); provenanceConnector.setInvocationContext(context); pa = provenanceConnector.getProvenanceAnalysis(); pa.setInvocationContext(context); pq = provenanceConnector.getQuery(); pw = provenanceConnector.getWriter(); pw.setQuery(pq); logger.info("using writer of type: "+pw.getClass().toString()); }
@Override /** * Used to construct a Job of empty lists at the appropriate depth in the * event of a completion hitting the crystalizer before it sees a child * node, i.e. the result of iterating over an empty collection structure of * some kind. */ public Job getEmptyJob(String owningProcess, int[] index, InvocationContext context) { int wrappingDepth = parent.resultWrappingDepth; if (wrappingDepth < 0) throw new RuntimeException( "Processor ["+owningProcess+"] hasn't been configured, cannot emit empty job"); // The wrapping depth is the length of index array that would be used if // a single item of the output port type were returned. We can examine // the index array for the node we're trying to create and use this to // work out how much we need to add to the output port depth to create // empty lists of the right type given the index array. int depth = wrappingDepth - index.length; // TODO - why was this incrementing? // depth++; ReferenceService rs = context.getReferenceService(); Map<String, T2Reference> emptyJobMap = new HashMap<String, T2Reference>(); for (OutputPort op : parent.getOutputPorts()) { emptyJobMap.put(op.getName(), rs.getListService() .registerEmptyList(depth + op.getDepth(), context).getId()); } return new Job(owningProcess, index, emptyJobMap, context); }
public void run() { try { ReferenceService referenceService = callback.getContext().getReferenceService(); XMLInputSplitter splitter = createSplitter(); Map<String,Object> inputMap = buildInputMap(data,referenceService); Map<String,String> outputMap = splitter.execute(inputMap); callback.receiveResult(createOutputData(outputMap,referenceService), new int[0]); } catch(Exception e) { callback.fail("Error in XMLInputSplitterActivity",e); } }
public void run() { try { ReferenceService referenceService = callback.getContext().getReferenceService(); XMLInputSplitter splitter = createSplitter(); Map<String,Object> inputMap = buildInputMap(data,referenceService); Map<String,String> outputMap = splitter.execute(inputMap); callback.receiveResult(createOutputData(outputMap,referenceService), new int[0]); } catch(Exception e) { callback.fail("Error in XMLInputSplitterActivity",e); } }
public void run() { try { ReferenceService referenceService = callback.getContext() .getReferenceService(); XMLOutputSplitter splitter = createSplitter(); Map<String, String> inputMap = buildInputMap(data, referenceService); Map<String, Object> outputMap = splitter.execute(inputMap); callback.receiveResult(createOutputData(outputMap, referenceService), new int[0]); } catch (Exception e) { callback.fail("Error in XMLInputSplitterActivity", e); } }
public void run() { try { ReferenceService referenceService = callback.getContext() .getReferenceService(); XMLOutputSplitter splitter = createSplitter(); Map<String, String> inputMap = buildInputMap(data, referenceService); Map<String, Object> outputMap = splitter.execute(inputMap); callback.receiveResult(createOutputData(outputMap, referenceService), new int[0]); } catch (Exception e) { callback.fail("Error in XMLInputSplitterActivity", e); } }
@Test @Ignore public void testInitDefaultReferenceService() throws Exception { String driver = "org.apache.derby.jdbc.EmbeddedDriver"; File tempDir = File.createTempFile("install", "dir"); tempDir.delete(); tempDir.mkdir(); String jdbcUrl= "jdbc:derby:"+tempDir.toString()+"/database;create=true;upgrade=true"; ProvenanceAccess.initDataSource(driver, jdbcUrl); ProvenanceAccess provenanceAccess = new ProvenanceAccess(ProvenanceConnectorType.DERBY, Collections.<ProvenanceConnectorFactory>emptyList()); provenanceAccess.initDefaultReferenceService(); assertNotNull(provenanceAccess.provenanceConnector.getInvocationContext()); assertNotNull(provenanceAccess.provenanceConnector.getInvocationContext().getReferenceService()); assertEquals(provenanceAccess.provenanceConnector.getReferenceService(),provenanceAccess.provenanceConnector.getInvocationContext().getReferenceService()); }
/** * Populate an {@link OutputDataProvenanceItem} with the results and attach * it to the appropriate {@link IterationProvenanceItem}. Then send the * {@link IterationProvenanceItem} across to the {@link ProvenanceConnector} */ @Override public void receiveResult(DispatchResultEvent resultEvent) { // FIXME use the connector from the result event context IterationProvenanceItem iterationProvItem = getIterationProvItem(resultEvent); ReferenceService referenceService = resultEvent.getContext() .getReferenceService(); OutputDataProvenanceItem outputDataItem = new OutputDataProvenanceItem( resultEvent.getData(), referenceService); outputDataItem.setIdentifier(UUID.randomUUID().toString()); outputDataItem.setProcessId(resultEvent.getOwningProcess()); outputDataItem.setParentId(iterationProvItem.getIdentifier()); iterationProvItem.setOutputDataItem(outputDataItem); getConnector().addProvenanceItem(iterationProvItem); // getConnector().addProvenanceItem(outputDataItem); super.receiveResult(resultEvent); }
public void pushToken(WorkflowDataToken dt, String owningProcess, int desiredDepth) { if (dt.getData().getDepth() == desiredDepth) { pushData(getName(), owningProcess, dt.getIndex(), dt.getData(), dt .getContext()); } else { ReferenceService rs = dt.getContext().getReferenceService(); Iterator<ContextualizedT2Reference> children = rs.traverseFrom(dt .getData(), dt.getData().getDepth() - 1); while (children.hasNext()) { ContextualizedT2Reference ci = children.next(); int[] newIndex = new int[dt.getIndex().length + ci.getIndex().length]; int i = 0; for (int indx : dt.getIndex()) { newIndex[i++] = indx; } for (int indx : ci.getIndex()) { newIndex[i++] = indx; } pushToken(new WorkflowDataToken(owningProcess, newIndex, ci .getReference(), dt.getContext()), owningProcess, desiredDepth); } pushCompletion(getName(), owningProcess, dt.getIndex(), dt .getContext()); } }