001package de.deepamehta.core.impl;
002
003import de.deepamehta.core.AssociationType;
004import de.deepamehta.core.model.AssociationDefinitionModel;
005import de.deepamehta.core.model.AssociationModel;
006import de.deepamehta.core.model.AssociationTypeModel;
007import de.deepamehta.core.model.SimpleValue;
008import de.deepamehta.core.model.TypeModel;
009import de.deepamehta.core.service.Directive;
010
011import java.util.List;
012
013
014
015/**
016 * Data that underlies a {@link AssociationType}.
017 *
018 * @author <a href="mailto:jri@deepamehta.de">Jörg Richter</a>
019 */
020public class AssociationTypeModelImpl extends TypeModelImpl implements AssociationTypeModel {
021
022    // ---------------------------------------------------------------------------------------------------- Constructors
023
024    AssociationTypeModelImpl(TypeModelImpl type) {
025        super(type);
026    }
027
028    // -------------------------------------------------------------------------------------------------- Public Methods
029
030    @Override
031    public AssociationTypeModel addAssocDef(AssociationDefinitionModel assocDef) {
032        return (AssociationTypeModel) super.addAssocDef(assocDef);
033    }
034
035    // ---
036
037    @Override
038    public String toString() {
039        return "association type (" + super.toString() + ")";
040    }
041
042    // ----------------------------------------------------------------------------------------- Package Private Methods
043
044    @Override
045    String className() {
046        return "association type";
047    }
048
049    @Override
050    AssociationType instantiate() {
051        return new AssociationTypeImpl(this, pl);
052    }
053
054
055
056    // === Implementation of abstract TypeModelImpl methods ===
057
058    @Override
059    List<AssociationModelImpl> getAllInstances() {
060        return pl.fetchAssociations("type_uri", new SimpleValue(uri));
061    }
062
063    // ---
064
065    @Override
066    Directive getUpdateTypeDirective() {
067        return Directive.UPDATE_ASSOCIATION_TYPE;
068    }
069
070    @Override
071    Directive getDeleteTypeDirective() {
072        return Directive.DELETE_ASSOCIATION_TYPE;
073    }
074}