ServiceImpl.java revision 18
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// The MIT License
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber//
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// Copyright (c) 2004 Evren Sirin
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber//
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// Permission is hereby granted, free of charge, to any person obtaining a copy
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// of this software and associated documentation files (the "Software"), to
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// deal in the Software without restriction, including without limitation the
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// sell copies of the Software, and to permit persons to whom the Software is
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// furnished to do so, subject to the following conditions:
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber//
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// The above copyright notice and this permission notice shall be included in
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// all copies or substantial portions of the Software.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber//
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
250b1eec71b074acdff1c5f6b5a1f0d7d2c20b77Stéphane Graber// IN THE SOFTWARE.
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberpackage impl.owls.service;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
7f95145833bb24f54e037f73ecc37444d6635697Dwight Engenimport impl.owl.WrappedIndividual;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberimport org.mindswap.owl.OWLDataValueList;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberimport org.mindswap.owl.OWLIndividual;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberimport org.mindswap.owls.grounding.Grounding;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberimport org.mindswap.owls.process.Process;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberimport org.mindswap.owls.profile.Profile;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberimport org.mindswap.owls.service.Service;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberimport org.mindswap.owls.vocabulary.OWLS;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graberpublic class ServiceImpl extends WrappedIndividual implements Service {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public ServiceImpl(OWLIndividual ind) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber super(ind);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /**
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @return
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public Process getProcess() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return (Process) getPropertyAs(OWLS.Service.describedBy, Process.class);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /**
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @return
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public Profile getProfile() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return (Profile) getPropertyAs(OWLS.Service.presents, Profile.class);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /**
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @param process
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void setProcess(Process process) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber if(hasProperty(OWLS.Service.describedBy, process))
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber setProperty(OWLS.Service.describedBy, process);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber process.setService(this);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /**
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @param profile
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void setProfile(Profile profile) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber if(hasProperty(OWLS.Service.presents, profile))
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber setProperty(OWLS.Service.presents, profile);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber profile.setService(this);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /* (non-Javadoc)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @see org.mindswap.owls.service.Service#getGrounding()
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public Grounding getGrounding() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return (Grounding) getPropertyAs(OWLS.Service.supports, Grounding.class);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /**
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @param grounding
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void setGrounding(Grounding grounding) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber if(hasProperty(OWLS.Service.supports, grounding))
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber setProperty(OWLS.Service.supports, grounding);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber grounding.setService(this);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public String debugString() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber String str = "Service " + getLabel() + " " + getURI() + "\n";
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber str += "Profile " + getProfile().debugString() + "\n";
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber str += "Process " + getProcess().debugString() + "\n";
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return str;
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /* (non-Javadoc)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @see org.mindswap.owls.service.Service#getName()
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public String getName() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber Profile profile = getProfile();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return profile == null ? null : profile.getServiceName();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /* (non-Javadoc)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @see org.mindswap.owls.service.Service#getName(java.lang.String)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public String getName(String lang) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber Profile profile = getProfile();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return profile == null ? null : profile.getServiceName(lang);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void setName(String name) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber Profile profile = getProfile();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber if(profile != null)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber profile.setServiceName(name);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber /* (non-Javadoc)
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber * @see org.mindswap.owls.service.Service#getNames()
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber */
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public OWLDataValueList getNames() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber Profile profile = getProfile();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber return profile == null ? null : profile.getServiceNames();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void removeGrounding(Grounding grounding) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber if (hasProperty(OWLS.Service.supports, grounding))
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber removeProperty(OWLS.Service.supports, grounding);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber grounding.removeService();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void removeProcess() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber getProcess().removeService();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi if (hasProperty(OWLS.Service.describedBy))
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi removeProperties(OWLS.Service.describedBy);
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi }
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi public void removeProfile(Profile profile) {
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi if (hasProperty(OWLS.Service.presents, profile))
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi removeProperty(OWLS.Service.presents, profile);
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi profile.removeService();
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi }
8128cf421081b683bca4610aa2db3e3ed851ab92KATOH Yasufumi
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void deleteGrounding(Grounding grounding) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber removeGrounding(grounding);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber grounding.delete();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void deleteProcess() {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber Process process = getProcess();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber removeProcess();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber process.delete();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber public void deleteProfile(Profile profile) {
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber removeProfile(profile);
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber profile.delete();
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber }
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber}
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber