ingo@346: package de.intevation.flys.artifacts.model; ingo@346: ingo@945: import org.w3c.dom.Document; ingo@945: import org.w3c.dom.Element; ingo@945: import org.w3c.dom.Node; ingo@945: ingo@945: import de.intevation.artifacts.ArtifactNamespaceContext; ingo@945: ingo@945: import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; ingo@945: ingo@346: import de.intevation.artifactdatabase.state.DefaultFacet; sascha@1061: import de.intevation.artifactdatabase.state.Facet; ingo@346: felix@1624: felix@1624: /** felix@1624: * Facet with user-supplied theme-control-information (pos in list, felix@1624: * active/disabled etc) attached. felix@1624: */ ingo@346: public class ManagedFacet extends DefaultFacet { ingo@346: felix@1624: /** The uuid of the owner artifact. */ ingo@346: protected String uuid; ingo@346: felix@1624: /** A property that determines the position of this facet. */ ingo@346: protected int position; ingo@346: felix@1624: /** A property that determines if this facet is active or not. */ ingo@346: protected int active; ingo@346: sascha@1061: public ManagedFacet() { sascha@1061: } ingo@346: ingo@346: public ManagedFacet( ingo@346: String name, ingo@694: int index, ingo@346: String desc, ingo@346: String uuid, ingo@346: int pos, ingo@346: int active) ingo@346: { ingo@694: super(index, name, desc); ingo@346: ingo@346: this.uuid = uuid; ingo@346: this.position = pos; ingo@346: this.active = active; ingo@346: } ingo@346: ingo@346: ingo@346: public void setPosition(int pos) { ingo@346: this.position = pos; ingo@346: } ingo@346: ingo@346: ingo@346: public int getPosition() { ingo@346: return position; ingo@346: } ingo@346: ingo@346: ingo@346: public void setActive(int active) { ingo@346: this.active = active; ingo@346: } ingo@346: ingo@346: ingo@346: public int getActive() { ingo@346: return active; ingo@346: } ingo@346: ingo@346: ingo@346: public String getArtifact() { ingo@346: return uuid; ingo@346: } ingo@945: ingo@945: ingo@945: public Node toXML(Document doc) { ingo@945: ElementCreator ec = new ElementCreator( ingo@945: doc, ingo@945: ArtifactNamespaceContext.NAMESPACE_URI, ingo@945: ArtifactNamespaceContext.NAMESPACE_PREFIX); ingo@945: ingo@945: Element facet = ec.create("theme"); ingo@945: ec.addAttr(facet, "artifact", getArtifact(), true); ingo@945: ec.addAttr(facet, "facet", getName(), true); ingo@945: ec.addAttr(facet, "pos", String.valueOf(getPosition()), true); ingo@945: ec.addAttr(facet, "active", String.valueOf(getActive()), true); ingo@945: ec.addAttr(facet, "index", String.valueOf(getIndex()), true); ingo@945: ec.addAttr(facet, "description", getDescription(), true); ingo@945: ingo@945: return facet; ingo@945: } sascha@1061: sascha@1061: public void set(ManagedFacet other) { sascha@1061: uuid = other.uuid; sascha@1061: position = other.position; sascha@1061: active = other.active; sascha@1061: } sascha@1061: sascha@1061: @Override sascha@1061: public Facet deepCopy() { sascha@1061: ManagedFacet copy = new ManagedFacet(); sascha@1061: copy.set((DefaultFacet)this); sascha@1061: copy.set((ManagedFacet)this); sascha@1061: return copy; sascha@1061: } ingo@346: } ingo@346: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :