Repository.java 2.33 KB
Newer Older
/*
 * Copyright 2020 École des Mines de Saint-Étienne.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package fr.emse.gitlab.saref.entities.git;

import java.io.File;
import java.util.List;

import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;

import fr.emse.gitlab.saref.Constants;

/**
 *
 * @author maxime.lefrancois
 */
public class Repository {
    private final String name;
    private final File directory;
    private final String http_url_to_repo;
    private final List<Version> versions;
    private transient Resource resource;

    
    public Repository(String name, File directory, String http_url_to_repo, List<Version> versions) {
    	this.name = name;
    	this.directory = directory;
    	this.http_url_to_repo = http_url_to_repo;
    	this.versions = versions;
	}
    
    public String getName() {
		return name;
	}

    public Resource getResource() {
    	if(resource == null) {
    		resource = ResourceFactory.createResource(getNamespace());
    	}
    	return resource;
    }

    public String getNamespace() {
		if (name.equals("saref-core")) {
			return String.format("%score/", Constants.BASE);
		} else {
			return String.format("%s%s/", Constants.BASE, name);
		}
	}
	
    public String getPrefix() {
		if (name.equals("saref-core")) {
			return "saref:";
		} else {
			return String.format("s%s:", name.substring(5));
		}
	}
    
    public File getDirectory() {
		return directory;
	}
    
    public String getHttp_url_to_repo() {
		return http_url_to_repo;
	}
    	
    public List<Version> getVersions() {
		return versions;
	}

	public String getOntologyFileName() {
		if (name.equals("saref-core")) {
			return "saref.ttl";
		} else {
			return String.format("%s.ttl", name);
		}
	}

	

}