@Override public ImmutableGraph getExecutionPlan() throws ChainException { return internalChain.getExecutionPlan(); }
@Override public Set<String> getEngines() throws ChainException { return internalChain.getEngines(); }
@GET @Path("/ep") @Produces(value = {JSON_LD, APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON, RDF_XML, TURTLE, X_TURTLE}) public Response getExecutionPlan(@Context HttpHeaders headers) { ResponseBuilder res; Chain chain = null; try { chain = getChain(); res = Response.ok(chain.getExecutionPlan()); } catch (ChainException e) { String chainName = chain == null ? "" : ("'"+chain.getName()+"' "); res = Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity("The Enhancement Chain "+chainName+"is currently" + "not executeable (message: "+e.getMessage()+")!"); } //addCORSOrigin(servletContext, res, headers); return res.build(); }
@Override public List<String> getChainNames() throws InvalidSyntaxException { List<String> chainNames = new ArrayList<String>(); BundleContext bundleContext = context.getBundleContext(); ServiceReference[] references = bundleContext.getServiceReferences(Chain.class.getName(), null); if (references != null) { for (ServiceReference ref : references) { Chain chain = (Chain) bundleContext.getService(ref); try { if (chain.getEngines().contains(getName())) { chainNames.add(chain.getName()); } } catch (ChainException e) { // This chain is currently not active ... ignore } } } return chainNames; }
try{ PDBFileReader read=new PDBFileReader(); Structure pdb=read.getStructure(filename); System.out.println("PDB code :"+pdb.getPDBCode()); List chains=Collections.synchronizedList(new ArrayList()); chains=pdb.getChains(); for(Iterator iter=chains.iterator();iter.hasNext();){ Chain c=(Chain)(iter.next()); System.out.println("Chain :"+c.getName()+"\n"+"Seq aa :"+c.getAtomSequence()); for(int j=0;j<c.getAtomLength();j++){ for (int k=0; k < c.getAtomGroup(j).size(); k++ ){ Atom a=c.getAtomGroup(j).getAtom(k); System.out.println("Name : "+a.getName()+" X : "+a.getX()+" Y : "+a.getY()+" Z : "+a.getZ()); } }
@GET @Path("/ep") @Produces(value = {JSON_LD, APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON, RDF_XML, TURTLE, X_TURTLE}) public Response getExecutionPlan(@Context HttpHeaders headers) { ResponseBuilder res; Chain chain = null; try { chain = getChain(); res = Response.ok(chain.getExecutionPlan()); } catch (ChainException e) { String chainName = chain == null ? "" : ("'"+chain.getName()+"' "); res = Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity("The Enhancement Chain "+chainName+"is currently" + "not executeable (message: "+e.getMessage()+")!"); } //addCORSOrigin(servletContext, res, headers); return res.build(); }
@Override public List<String> getChainNames() throws InvalidSyntaxException { List<String> chainNames = new ArrayList<String>(); BundleContext bundleContext = context.getBundleContext(); ServiceReference[] references = bundleContext.getServiceReferences(Chain.class.getName(), null); if (references != null) { for (ServiceReference ref : references) { Chain chain = (Chain) bundleContext.getService(ref); try { if (chain.getEngines().contains(getName())) { chainNames.add(chain.getName()); } } catch (ChainException e) { // This chain is currently not active ... ignore } } } return chainNames; }
@Override public List<EnhancementEngine> getActiveEngines() { //This implementation return the list of active engined for the default //Chain in the order they would be executed Chain defaultChain = chainManager.getDefault(); if(defaultChain == null){ throw new IllegalStateException("Currently no enhancement chain is " + "active. Please configure a Chain or enable the default chain"); } ImmutableGraph ep; try { ep = defaultChain.getExecutionPlan(); } catch (ChainException e) { throw new IllegalStateException("Unable to get Execution Plan for " + "default enhancement chain (name: '"+defaultChain.getName()+ "'| class: '"+defaultChain.getClass()+"')!",e); } return ExecutionPlanHelper.getActiveEngines(engineManager,ep); }
/** * Getter for the executionNodes * * @return */ public Set<ExecutionNode> getExecutionNodes() { if (_executionNodes == null) { ImmutableGraph ep; try { ep = chain.getExecutionPlan(); } catch (ChainException e) { ep = null; } if (ep != null) { _executionNodes = new LinkedHashSet<ExecutionNode>(); Set<BlankNodeOrIRI> processed = new HashSet<BlankNodeOrIRI>(); Set<BlankNodeOrIRI> next; do { next = ExecutionPlanHelper.getExecutable(ep, processed); for (BlankNodeOrIRI node : next) { _executionNodes.add(new ExecutionNode(ep, node)); } processed.addAll(next); } while (!next.isEmpty()); } } return _executionNodes; }
enhancementJobManagerLog.debug(">> enhance {} with chain {}", ci.getUri(), chain.getName()); boolean isDefaultChain = chain.equals(chainManager.getDefault()); EnhancementJob job = new EnhancementJob(ci, chain.getName(), chain.getExecutionPlan(),isDefaultChain); new Object[]{ chain.getName(), job.isFailed() ? "failed" : "finished", System.currentTimeMillis()-start, job.getContentItem().getUri()});
public boolean isDefault(String name){ return chainTracker.getDefault().getName().equals(name); }
/** * Getter for the executionNodes * * @return */ public Set<ExecutionNode> getExecutionNodes() { if (_executionNodes == null) { ImmutableGraph ep; try { ep = chain.getExecutionPlan(); } catch (ChainException e) { ep = null; } if (ep != null) { _executionNodes = new LinkedHashSet<ExecutionNode>(); Set<BlankNodeOrIRI> processed = new HashSet<BlankNodeOrIRI>(); Set<BlankNodeOrIRI> next; do { next = ExecutionPlanHelper.getExecutable(ep, processed); for (BlankNodeOrIRI node : next) { _executionNodes.add(new ExecutionNode(ep, node)); } processed.addAll(next); } while (!next.isEmpty()); } } return _executionNodes; }
public boolean isDefault(String name){ return chainTracker.getDefault().getName().equals(name); }
/** * Create the RDF data for the currently active Enhancement {@link Chain}s.<p> * Note the the parsed rootUrl MUST already consider offsets configured * for the Stanbol RESTful service. When called from within a * {@link BaseStanbolResource} the following code segment should be used:<p> * <code><pre> * String rootUrl = uriInfo.getBaseUriBuilder().path(getRootUrl()).build().toString(); * </pre></code> * @param activeChains the active enhancement chains as {@link Entry entries}. * @param defaultChain the default chain * @param graph the RDF graph to add the triples * @param rootUrl the root URL used by the current request */ public static void addActiveChains(Iterable<Entry<ServiceReference,Chain>> activeChains, Chain defaultChain, Graph graph, String rootUrl) { IRI enhancer = new IRI(rootUrl+"enhancer"); graph.add(new TripleImpl(enhancer, RDF.type, Enhancer.ENHANCER)); for(Entry<ServiceReference,Chain> entry : activeChains){ IRI chainResource = new IRI(rootUrl+"enhancer/chain/"+entry.getValue().getName()); graph.add(new TripleImpl(enhancer, Enhancer.HAS_CHAIN, chainResource)); if(entry.getValue().equals(defaultChain)){ graph.add(new TripleImpl(enhancer, Enhancer.HAS_DEFAULT_CHAIN, chainResource)); } graph.add(new TripleImpl(chainResource, RDF.type, Enhancer.ENHANCEMENT_CHAIN)); graph.add(new TripleImpl(chainResource, RDFS.label, new PlainLiteralImpl(entry.getValue().getName()))); } } }
/** * Create the RDF data for the currently active Enhancement {@link Chain}s.<p> * Note the the parsed rootUrl MUST already consider offsets configured * for the Stanbol RESTful service. When called from within a * {@link BaseStanbolResource} the following code segment should be used:<p> * <code><pre> * String rootUrl = uriInfo.getBaseUriBuilder().path(getRootUrl()).build().toString(); * </pre></code> * @param activeChains the active enhancement chains as {@link Entry entries}. * @param defaultChain the default chain * @param graph the RDF graph to add the triples * @param rootUrl the root URL used by the current request */ public static void addActiveChains(Iterable<Entry<ServiceReference,Chain>> activeChains, Chain defaultChain, Graph graph, String rootUrl) { IRI enhancer = new IRI(rootUrl+"enhancer"); graph.add(new TripleImpl(enhancer, RDF.type, Enhancer.ENHANCER)); for(Entry<ServiceReference,Chain> entry : activeChains){ IRI chainResource = new IRI(rootUrl+"enhancer/chain/"+entry.getValue().getName()); graph.add(new TripleImpl(enhancer, Enhancer.HAS_CHAIN, chainResource)); if(entry.getValue().equals(defaultChain)){ graph.add(new TripleImpl(enhancer, Enhancer.HAS_DEFAULT_CHAIN, chainResource)); } graph.add(new TripleImpl(chainResource, RDF.type, Enhancer.ENHANCEMENT_CHAIN)); graph.add(new TripleImpl(chainResource, RDFS.label, new PlainLiteralImpl(entry.getValue().getName()))); } } }