| /******************************************************************************* |
| * Copyright (C) 2021 the Eclipse BaSyx Authors |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| ******************************************************************************/ |
| package org.eclipse.basyx.submodel.metamodel.map.parts; |
| |
| import java.util.Collection; |
| import java.util.HashSet; |
| import java.util.Map; |
| |
| import org.eclipse.basyx.aas.metamodel.exception.MetamodelConstructionException; |
| import org.eclipse.basyx.submodel.metamodel.api.dataspecification.IEmbeddedDataSpecification; |
| import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier; |
| import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType; |
| import org.eclipse.basyx.submodel.metamodel.api.parts.IConceptDescription; |
| import org.eclipse.basyx.submodel.metamodel.api.qualifier.IAdministrativeInformation; |
| import org.eclipse.basyx.submodel.metamodel.api.reference.IReference; |
| import org.eclipse.basyx.submodel.metamodel.api.reference.enums.KeyElements; |
| import org.eclipse.basyx.submodel.metamodel.map.modeltype.ModelType; |
| import org.eclipse.basyx.submodel.metamodel.map.qualifier.AdministrativeInformation; |
| import org.eclipse.basyx.submodel.metamodel.map.qualifier.HasDataSpecification; |
| import org.eclipse.basyx.submodel.metamodel.map.qualifier.Identifiable; |
| import org.eclipse.basyx.submodel.metamodel.map.qualifier.LangStrings; |
| import org.eclipse.basyx.submodel.metamodel.map.qualifier.Referable; |
| import org.eclipse.basyx.submodel.metamodel.map.reference.Reference; |
| import org.eclipse.basyx.submodel.metamodel.map.reference.ReferenceHelper; |
| import org.eclipse.basyx.vab.model.VABModelMap; |
| |
| /** |
| * ConceptDescription class as described in DAAS document |
| * |
| * @author schnicke |
| * |
| */ |
| public class ConceptDescription extends VABModelMap<Object> implements IConceptDescription { |
| public static final String ISCASEOF = "isCaseOf"; |
| public static final String MODELTYPE = "ConceptDescription"; |
| |
| public ConceptDescription() { |
| // Add model type |
| putAll(new ModelType(MODELTYPE)); |
| |
| // Add qualifiers |
| putAll(new HasDataSpecification()); |
| putAll(new Identifiable()); |
| |
| // Add attributes |
| put(ISCASEOF, new HashSet<Reference>()); |
| } |
| |
| /** |
| * Constructor accepting only mandatory attribute |
| * @param idShort |
| * @param identification |
| */ |
| public ConceptDescription(String idShort, IIdentifier identification) { |
| this(); |
| setIdentification(identification.getIdType(), identification.getId()); |
| setIdShort(idShort); |
| } |
| |
| /** |
| * Creates a DataSpecificationIEC61360 object from a map |
| * |
| * @param obj |
| * a DataSpecificationIEC61360 object as raw map |
| * @return a DataSpecificationIEC61360 object, that behaves like a facade for |
| * the given map |
| */ |
| public static ConceptDescription createAsFacade(Map<String, Object> map) { |
| if (map == null) { |
| return null; |
| } |
| |
| if (!isValid(map)) { |
| throw new MetamodelConstructionException(ConceptDescription.class, map); |
| } |
| |
| ConceptDescription ret = new ConceptDescription(); |
| ret.setMap(map); |
| return ret; |
| } |
| |
| /** |
| * Check whether all mandatory elements for the metamodel |
| * exist in a map |
| * @return true/false |
| */ |
| public static boolean isValid(Map<String, Object> map) { |
| return Identifiable.isValid(map); |
| } |
| |
| @Override |
| public Collection<IReference> getDataSpecificationReferences() { |
| return HasDataSpecification.createAsFacade(this).getDataSpecificationReferences(); |
| } |
| |
| public void setDataSpecificationReferences(Collection<IReference> ref) { |
| HasDataSpecification.createAsFacade(this).setDataSpecificationReferences(ref); |
| } |
| |
| @Override |
| public Collection<IEmbeddedDataSpecification> getEmbeddedDataSpecifications() { |
| return HasDataSpecification.createAsFacade(this).getEmbeddedDataSpecifications(); |
| } |
| |
| public void setEmbeddedDataSpecifications(Collection<IEmbeddedDataSpecification> embeddedDataSpecifications) { |
| HasDataSpecification.createAsFacade(this).setEmbeddedDataSpecifications(embeddedDataSpecifications); |
| } |
| |
| @Override |
| public IAdministrativeInformation getAdministration() { |
| return Identifiable.createAsFacade(this, getKeyElement()).getAdministration(); |
| } |
| |
| @Override |
| public IIdentifier getIdentification() { |
| return Identifiable.createAsFacade(this, getKeyElement()).getIdentification(); |
| } |
| |
| public void setAdministration(AdministrativeInformation information) { |
| Identifiable.createAsFacade(this, getKeyElement()).setAdministration(information); |
| } |
| |
| public void setIdentification(IdentifierType idType, String id) { |
| Identifiable.createAsFacadeNonStrict(this, getKeyElement()).setIdentification(idType, id); |
| } |
| |
| @Override |
| public Collection<IReference> getIsCaseOf() { |
| return ReferenceHelper.transform(get(ConceptDescription.ISCASEOF)); |
| } |
| |
| public void setIsCaseOf(Collection<Reference> ref) { |
| put(ConceptDescription.ISCASEOF, ref); |
| } |
| |
| @Override |
| public String getIdShort() { |
| return Referable.createAsFacade(this, getKeyElement()).getIdShort(); |
| } |
| |
| @Override |
| public String getCategory() { |
| return Referable.createAsFacade(this, getKeyElement()).getCategory(); |
| } |
| |
| @Override |
| public LangStrings getDescription() { |
| return Referable.createAsFacade(this, getKeyElement()).getDescription(); |
| } |
| @Override |
| public IReference getParent() { |
| return Referable.createAsFacade(this, getKeyElement()).getParent(); |
| } |
| |
| public void setIdShort(String idShort) { |
| Referable.createAsFacadeNonStrict(this, getKeyElement()).setIdShort(idShort); |
| |
| } |
| |
| public void setCategory(String category) { |
| Referable.createAsFacade(this, getKeyElement()).setCategory(category); |
| |
| } |
| |
| public void setDescription(LangStrings description) { |
| Referable.createAsFacade(this, getKeyElement()).setDescription(description); |
| } |
| |
| public void setParent(IReference obj) { |
| Referable.createAsFacade(this, getKeyElement()).setParent(obj); |
| } |
| |
| private KeyElements getKeyElement() { |
| return KeyElements.CONCEPTDESCRIPTION; |
| } |
| |
| @Override |
| public IReference getReference() { |
| return Identifiable.createAsFacade(this, getKeyElement()).getReference(); |
| } |
| |
| } |