public void run() { try { callback.augmentationCompleted(augmentReferenceSet( references, targetReferenceTypes, context)); } catch (ReferenceSetAugmentationException rsae) { callback.augmentationFailed(rsae); } } };
/** * {@inheritDoc} */ public final void augmentReferenceSetAsynch(final ReferenceSet references, final Set<Class<ExternalReferenceSPI>> targetReferenceTypes, final ReferenceContext context, final ReferenceSetAugmentorCallback callback) throws ReferenceSetAugmentationException { Runnable r = new Runnable() { public void run() { try { callback.augmentationCompleted(augmentReferenceSet( references, targetReferenceTypes, context)); } catch (ReferenceSetAugmentationException rsae) { callback.augmentationFailed(rsae); } } }; executeRunnable(r); }
update(); .doTranslation(references, context); log.debug(" Success (" + counter + "), created " + printRefSet(newReferences)); return newReferences; } catch (Exception ex) {
@SuppressWarnings("unchecked") protected synchronized final void update() { if (builders == null || translators == null || cacheValid) { return; } log.debug("# Refreshing shortest path cache"); knownReferenceTypes.clear(); solvers.clear(); adjacencySets.clear(); for (ExternalReferenceBuilderSPI erb : builders) { knownReferenceTypes.add(erb.getReferenceType()); } for (ExternalReferenceTranslatorSPI ert : translators) { knownReferenceTypes.add(ert.getSourceReferenceType()); knownReferenceTypes.add(ert.getTargetReferenceType()); getNeighbours(ert.getTargetReferenceType()).add(ert); } for (Class<ExternalReferenceSPI> type : knownReferenceTypes) { try { solvers.put(type, new ShortestPathSolver(type)); } catch (Throwable t) { log.error(t); if (t instanceof RuntimeException) { throw (RuntimeException) t; } } } log.debug("# Path cache refresh done"); cacheValid = true; }
private static ReferenceService createReferenceService() { SimpleT2ReferenceGenerator referenceGenerator = new SimpleT2ReferenceGenerator(); ReferenceSetAugmentorImpl referenceSetAugmentor = new ReferenceSetAugmentorImpl(); referenceSetAugmentor.setBuilders((List<ExternalReferenceBuilderSPI<?>>) getBuilders()); referenceSetAugmentor.setTranslators(getTranslators()); ReferenceSetServiceImpl referenceSetService = new ReferenceSetServiceImpl(); referenceSetService.setT2ReferenceGenerator(referenceGenerator); referenceSetService.setReferenceSetDao(new InMemoryReferenceSetDao()); referenceSetService.setReferenceSetAugmentor(referenceSetAugmentor); ListServiceImpl listService = new ListServiceImpl(); listService.setT2ReferenceGenerator(referenceGenerator); listService.setListDao(new InMemoryListDao()); ErrorDocumentServiceImpl errorDocumentService = new ErrorDocumentServiceImpl(); errorDocumentService.setT2ReferenceGenerator(referenceGenerator); errorDocumentService.setErrorDao(new InMemoryErrorDocumentDao()); ReferenceServiceImpl referenceService = new ReferenceServiceImpl(); referenceService.setReferenceSetService(referenceSetService); referenceService.setListService(listService); referenceService.setErrorDocumentService(errorDocumentService); referenceService.setConverters(getConverters()); referenceService.setValueBuilders(getValueBuilders()); return referenceService; }
update(); context); log.debug(" Success (" + counter + "), created " + printRefSet(newReferences)); return newReferences; } catch (Exception ex) {
@SuppressWarnings("unchecked") protected synchronized final void update() { if (builders == null || translators == null || cacheValid) { return; } log.debug("# Refreshing shortest path cache"); knownReferenceTypes.clear(); solvers.clear(); adjacencySets.clear(); for (ExternalReferenceBuilderSPI erb : builders) { knownReferenceTypes.add(erb.getReferenceType()); } for (ExternalReferenceTranslatorSPI ert : translators) { knownReferenceTypes.add(ert.getSourceReferenceType()); knownReferenceTypes.add(ert.getTargetReferenceType()); getNeighbours(ert.getTargetReferenceType()).add(ert); } for (Class<ExternalReferenceSPI> type : knownReferenceTypes) { try { solvers.put(type, new ShortestPathSolver(type)); } catch (Throwable t) { t.printStackTrace(); if (t instanceof RuntimeException) { throw (RuntimeException) t; } } } log.debug("# Path cache refresh done"); cacheValid = true; }
update(); Set<ExternalReferenceSPI> newReferences = path .doTranslation(references, context); log.debug(" Success ("+counter+"), created "+printRefSet(newReferences)); return newReferences; } catch (Exception ex) {
@SuppressWarnings("unchecked") protected synchronized final void update() { if (builders == null || translators == null || cacheValid) { return; } log.debug("# Refreshing shortest path cache"); knownReferenceTypes.clear(); solvers.clear(); adjacencySets.clear(); for (ExternalReferenceBuilderSPI erb : builders) { knownReferenceTypes.add(erb.getReferenceType()); } for (ExternalReferenceTranslatorSPI ert : translators) { knownReferenceTypes.add(ert.getSourceReferenceType()); knownReferenceTypes.add(ert.getTargetReferenceType()); getNeighbours(ert.getTargetReferenceType()).add(ert); } for (Class<ExternalReferenceSPI> type : knownReferenceTypes) { try { solvers.put(type, new ShortestPathSolver(type)); } catch (Throwable t) { t.printStackTrace(); if (t instanceof RuntimeException) { throw (RuntimeException) t; } } } log.debug("# Path cache refresh done"); cacheValid = true; }
public void run() { try { callback.augmentationCompleted(augmentReferenceSet(references, targetReferenceTypes, context)); } catch (ReferenceSetAugmentationException rsae) { callback.augmentationFailed(rsae); } } };
/** * {@inheritDoc} */ public final void augmentReferenceSetAsynch(final ReferenceSet references, final Set<Class<ExternalReferenceSPI>> targetReferenceTypes, final ReferenceContext context, final ReferenceSetAugmentorCallback callback) throws ReferenceSetAugmentationException { Runnable r = new Runnable() { public void run() { try { callback.augmentationCompleted(augmentReferenceSet(references, targetReferenceTypes, context)); } catch (ReferenceSetAugmentationException rsae) { callback.augmentationFailed(rsae); } } }; executeRunnable(r); }
@SuppressWarnings("unchecked") private void relaxNeighbours(Class<ExternalReferenceSPI> u) { log.trace("# relaxing node " + u.getSimpleName()); Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<Class<ExternalReferenceSPI>>(); for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) { // all the translators that translate *to* u Class<ExternalReferenceSPI> v = ert.getSourceReferenceType(); log.trace("# translator found from from '" + v + "' : " + ert.getClass().getSimpleName()); if (alreadySeen.contains(v) == false && isSettled(v) == false) { // Avoid duplicate edges, always take the first one where // such duplicates exist alreadySeen.add(v); if (getShortestDistance(v) > getShortestDistance(u) + ert.getTranslationCost()) { setShortestDistance(v, getShortestDistance(u) + ert.getTranslationCost()); setPredecessor(v, u, ert); unsettledNodes.add(v); } } } }
public void run() { try { callback.augmentationCompleted(augmentReferenceSet( references, targetReferenceTypes, context)); } catch (ReferenceSetAugmentationException rsae) { callback.augmentationFailed(rsae); } } };
/** * {@inheritDoc} */ public final void augmentReferenceSetAsynch(final ReferenceSet references, final Set<Class<ExternalReferenceSPI>> targetReferenceTypes, final ReferenceContext context, final ReferenceSetAugmentorCallback callback) throws ReferenceSetAugmentationException { Runnable r = new Runnable() { public void run() { try { callback.augmentationCompleted(augmentReferenceSet( references, targetReferenceTypes, context)); } catch (ReferenceSetAugmentationException rsae) { callback.augmentationFailed(rsae); } } }; executeRunnable(r); }
@SuppressWarnings("unchecked") private void relaxNeighbours(Class<ExternalReferenceSPI> u) { log.trace("# relaxing node " + u.getSimpleName()); Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<Class<ExternalReferenceSPI>>(); for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) { // all the translators that translate *to* u Class<ExternalReferenceSPI> v = ert.getSourceReferenceType(); log.trace("# translator found from from '" + v + "' : " + ert.getClass().getSimpleName()); if (alreadySeen.contains(v) == false && isSettled(v) == false) { // Avoid duplicate edges, always take the first one where // such duplicates exist alreadySeen.add(v); if (getShortestDistance(v) > getShortestDistance(u) + ert.getTranslationCost()) { setShortestDistance(v, getShortestDistance(u) + ert.getTranslationCost()); setPredecessor(v, u, ert); unsettledNodes.add(v); } } } }
@SuppressWarnings("unchecked") private void relaxNeighbours(Class<ExternalReferenceSPI> u) { log.trace("# relaxing node " + u.getSimpleName()); Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<Class<ExternalReferenceSPI>>(); for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) { // all the translators that translate *to* u Class<ExternalReferenceSPI> v = ert.getSourceReferenceType(); log.trace("# translator found from from '" + v + "' : " + ert.getClass().getSimpleName()); if (alreadySeen.contains(v) == false && isSettled(v) == false) { // Avoid duplicate edges, always take the first one where // such duplicates exist alreadySeen.add(v); if (getShortestDistance(v) > getShortestDistance(u) + ert.getTranslationCost()) { setShortestDistance(v, getShortestDistance(u) + ert.getTranslationCost()); setPredecessor(v, u, ert); unsettledNodes.add(v); } } } }