001package systems.dmx.core.impl;
002
003import systems.dmx.core.model.ChildTopicsModel;
004import systems.dmx.core.model.RelatedTopicModel;
005import systems.dmx.core.model.TopicModel;
006import systems.dmx.core.model.facets.FacetValueModel;
007import systems.dmx.core.service.ModelFactory;
008
009import java.util.HashMap;
010import java.util.List;
011
012
013
014class FacetValueModelImpl extends ChildTopicsModelImpl implements FacetValueModel {
015
016    // ---------------------------------------------------------------------------------------------- Instance Variables
017
018    private String childTypeUri;
019
020    // ---------------------------------------------------------------------------------------------------- Constructors
021
022    FacetValueModelImpl(String childTypeUri, ModelFactory mf) {
023        super(new HashMap(), mf);
024        this.childTypeUri = childTypeUri;
025    }
026
027    FacetValueModelImpl(ChildTopicsModelImpl childTopics) {
028        super(childTopics);
029        this.childTypeUri = iterator().next();
030    }
031
032    // -------------------------------------------------------------------------------------------------- Public Methods
033
034
035
036    // === Single-valued Facets ===
037
038    public RelatedTopicModel getTopic() {
039        return getTopic(childTypeUri);
040    }
041
042    public List<? extends RelatedTopicModel> getTopics() {
043        return getTopics(childTypeUri);
044    }
045
046    // ---
047
048    public FacetValueModel put(RelatedTopicModel value) {
049        return (FacetValueModel) put(childTypeUri, value);
050    }
051
052    public FacetValueModel put(TopicModel value) {
053        return (FacetValueModel) put(childTypeUri, value);
054    }
055
056    // ---
057
058    public FacetValueModel put(Object value) {
059        return (FacetValueModel) put(childTypeUri, value);
060    }
061
062    public FacetValueModel put(ChildTopicsModel value) {
063        return (FacetValueModel) put(childTypeUri, value);
064    }
065
066    // ---
067
068    public FacetValueModel putRef(long refTopicId) {
069        return (FacetValueModel) putRef(childTypeUri, refTopicId);
070    }
071
072    public FacetValueModel putRef(String refTopicUri) {
073        return (FacetValueModel) putRef(childTypeUri, refTopicUri);
074    }
075
076    // ---
077
078    public FacetValueModel putDeletionRef(long refTopicId) {
079        return (FacetValueModel) putDeletionRef(childTypeUri, refTopicId);
080    }
081
082    public FacetValueModel putDeletionRef(String refTopicUri) {
083        return (FacetValueModel) putDeletionRef(childTypeUri, refTopicUri);
084    }
085
086
087
088    // === Multiple-valued Facets ===
089
090    public FacetValueModel put(List<RelatedTopicModel> values) {
091        return (FacetValueModel) put(childTypeUri, values);
092    }
093
094    // ---
095
096    public FacetValueModel addRef(long refTopicId) {
097        return (FacetValueModel) addRef(childTypeUri, refTopicId);
098    }
099
100    public FacetValueModel addRef(String refTopicUri) {
101        return (FacetValueModel) addRef(childTypeUri, refTopicUri);
102    }
103
104    // ---
105
106    public FacetValueModel addDeletionRef(long refTopicId) {
107        return (FacetValueModel) addDeletionRef(childTypeUri, refTopicId);
108    }
109
110    public FacetValueModel addDeletionRef(String refTopicUri) {
111        return (FacetValueModel) addDeletionRef(childTypeUri, refTopicUri);
112    }
113}