Package org.openbel.framework.core.df.beldata.namespace

Examples of org.openbel.framework.core.df.beldata.namespace.NamespaceHeaderParser


            BELDataMissingPropertyException, BELDataConversionException {
        if (instance == null) {
            instance = new Namespaces();

            final CacheableResourceService c = new DefaultCacheableResourceService();
            final NamespaceHeaderParser p = new NamespaceHeaderParser();

            final SystemConfiguration sysConfig = getSystemConfiguration();
            final String resourceIndexURL = sysConfig.getResourceIndexURL();
            File indexFile = new File(resourceIndexURL);
            if (!indexFile.exists() || !indexFile.canRead()) {
                // try the index as an online resource.
                ResolvedResource resolvedResource = c.resolveResource(
                        ResourceType.RESOURCE_INDEX, resourceIndexURL);
                indexFile = resolvedResource.getCacheResourceCopy();
            }

            final ResourceIndex ri = ResourceIndex.INSTANCE;
            ri.loadIndex(indexFile);
            final Index index = ri.getIndex();


            final List<ResourceLocation> nsr = index.getNamespaceResources();
            final Map<String, NamespaceHeader> hvals;
            if (hasItems(nsr)) {
                hvals = new LinkedHashMap<String, NamespaceHeader>(index
                        .getNamespaceResources().size());
                for (ResourceLocation rl : index.getNamespaceResources()) {
                    String loc = rl.getResourceLocation();
                    ResolvedResource nsResource = c.resolveResource(
                            ResourceType.NAMESPACES, loc);
                    NamespaceHeader header = p.parseNamespace(loc,
                            nsResource.getCacheResourceCopy());
                    hvals.put(loc, header);
                }
            } else {
                hvals = new LinkedHashMap<String, NamespaceHeader>();
View Full Code Here


     * {@inheritDoc}
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        logger.debug("Loading BEL namespaces");
        NamespaceHeaderParser parser = new NamespaceHeaderParser();
        this.headers = new HashMap<String, NamespaceHeader>(resourceIndex
                .getNamespaceResources().size());

        for (ResourceLocation rl : resourceIndex.getNamespaceResources()) {
            String loc = rl.getResourceLocation();
            ResolvedResource nsResource = cacheableResourceService
                    .resolveResource(ResourceType.NAMESPACES, loc);
            NamespaceHeader header = parser.parseNamespace(loc,
                    nsResource.getCacheResourceCopy());
            headers.put(loc, header);
        }
        logger.debug("Finished loading BEL namespaces");
    }
View Full Code Here

TOP

Related Classes of org.openbel.framework.core.df.beldata.namespace.NamespaceHeaderParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.