All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.protege.webprotege.crud.oboid.OboIdSuffixKit Maven / Gradle / Ivy

There is a newer version: 2.0.2-WHO
Show newest version
package edu.stanford.protege.webprotege.crud.oboid;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.collect.ImmutableList;
import edu.stanford.protege.webprotege.crud.EntityCrudKit;
import edu.stanford.protege.webprotege.crud.EntityCrudKitId;
import edu.stanford.protege.webprotege.crud.EntityCrudKitPrefixSettings;
import edu.stanford.protege.webprotege.crud.gen.GeneratedAnnotationsSettings;
import org.semanticweb.owlapi.model.IRI;

import javax.inject.Inject;
import java.util.Optional;

/**
 * Author: Matthew Horridge
* Stanford University
* Bio-Medical Informatics Research Group
* Date: 14/08/2013 */ @JsonTypeName("OboId") public class OboIdSuffixKit extends EntityCrudKit { public static final String DEFAULT_PREFIX = "http://purl.obolibrary.org/obo/ONT_"; private static final EntityCrudKitId ID = EntityCrudKitId.get("OBO"); @Inject public OboIdSuffixKit() { super(ID, "Auto-generated OBO Style Id"); } @JsonIgnore public static EntityCrudKitId getId() { return ID; } @Override public EntityCrudKitPrefixSettings getDefaultPrefixSettings() { return EntityCrudKitPrefixSettings.get(DEFAULT_PREFIX, ImmutableList.of()); } @Override public OboIdSuffixSettings getDefaultSuffixSettings() { return OboIdSuffixSettings.get(); } @Override public Optional getPrefixValidationMessage(String prefix) { if(prefix.endsWith(DEFAULT_PREFIX)) { return Optional.of("The default prefix is specified. You should change this to suit your ontology."); } else if(!prefix.endsWith("_")) { return Optional.of("OBO IRI prefixes should end with an underscore"); } else { return Optional.empty(); } } @Override public IRI generateExample(EntityCrudKitPrefixSettings prefixSettings, OboIdSuffixSettings suffixSettings) { StringBuilder sb = new StringBuilder(); sb.append("0".repeat(Math.max(0, suffixSettings.getTotalDigits() - 1))); sb.append("1"); return IRI.create(prefixSettings.getIRIPrefix(), sb.toString()); } @Override public GeneratedAnnotationsSettings getDefaultGeneratedAnnotationsSettings() { return GeneratedAnnotationsSettings.empty(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy