001: /*
002: * Copyright 2004 Outerthought bvba and Schaubroeck nv
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.outerj.daisy.repository.schema;
017:
018: import org.outerj.daisy.repository.RepositoryException;
019: import org.outerx.daisy.x10.DocumentTypeDocument;
020:
021: import java.util.Date;
022:
023: /**
024: * Describes a type of document in the repository.
025: *
026: * <p>Instances are retrieved from {@link RepositorySchema}.
027: *
028: * <p>A document type has some general properties like a name (which must
029: * be unique), and a locale-sensitive label and description. Next to these,
030: * a document type is associated with a number of {@link FieldType}s
031: * and {@link PartType}s.
032: *
033: * <p>The part types and field types belonging to a document type are
034: * ordered collections: the order in which you add them matters. To
035: * reorder them, first remove them all and re-add them.
036: *
037: * <p>A document type object can be read-only, in which case all state-modifying
038: * methods (i.e. all setters and the save method) will throw a RuntimeException.
039: * Whether a document type object is read-only or not depends on where you
040: * retrieved it from. The purpose of read-only document type objects is for
041: * caching, i.e. the same object can be used by multiple users who only which
042: * to consult the document type information, but not modify it.
043: *
044: * <p>The equals method for DocumentType is supported, two document types are
045: * equal if all their defining data is equal, with exception of the ID.
046: */
047: public interface DocumentType extends LabelEnabled, DescriptionEnabled {
048: long getId();
049:
050: /**
051: * Returns the part types contained by this document type. This is an ordered
052: * collection. The returned array is a newly created copy, thus modifying
053: * the order of the part types in the array, or putting other ones in it, won't
054: * modify this document type.
055: */
056: PartTypeUse[] getPartTypeUses();
057:
058: /**
059: * Adds a new association with a part type to this document type.
060: *
061: * <p>The supplied part type should already exist in the repository, i.e.
062: * it should have an id != -1.
063: *
064: * <p>The same part type can be added only once.
065: *
066: * <p>A part type is always added to the end, after the already existing part types.
067: *
068: * @throws IllegalArgumentException if the part type's id is -1, or if
069: * it is already contained by this document type.
070: */
071: PartTypeUse addPartType(PartType partType, boolean required);
072:
073: /**
074: * Removes all associations with part types.
075: */
076: void clearPartTypeUses();
077:
078: /**
079: * Checks if this document type contains the part type with the given ID.
080: */
081: boolean hasPartType(long id);
082:
083: /**
084: * Gets a 'part type use' by part type ID.
085: *
086: * @param id ID of the part type.
087: * @return null if the part type is not associated with this document type
088: */
089: PartTypeUse getPartTypeUse(long id);
090:
091: /**
092: * Gets a 'part type use' by part type name.
093: *
094: * @return null if the part type is not associated with this document type
095: */
096: PartTypeUse getPartTypeUse(String partTypeName);
097:
098: FieldTypeUse[] getFieldTypeUses();
099:
100: boolean hasFieldType(long id);
101:
102: /**
103: * Gets a 'field type use' by field type ID.
104: *
105: * @param id ID of the field type.
106: * @return null if the field type is not associated with this document type
107: */
108: FieldTypeUse getFieldTypeUse(long id);
109:
110: /**
111: * Gets a 'field type use' by field type name.
112: *
113: * @return null if the field type is not associated with this document type
114: */
115: FieldTypeUse getFieldTypeUse(String fieldTypeName);
116:
117: /**
118: * The suplied field type should already exist in the repository, i.e.
119: * it should have an id != -1.
120: *
121: * <p>A field type is always added to the end, after the already existing field types.
122: *
123: * <p>The same field type can only be added once.
124: */
125: FieldTypeUse addFieldType(FieldType type, boolean required);
126:
127: void clearFieldTypeUses();
128:
129: String getName();
130:
131: void setName(String name);
132:
133: boolean isDeprecated();
134:
135: void setDeprecated(boolean deprecated);
136:
137: /**
138: * When was this document type last changed (persistently). Returns null on newly
139: * created, not-yet-saved, document types.
140: */
141: Date getLastModified();
142:
143: /**
144: * Who (which user) last changed this document type (persistently). Returns -1 on
145: * newly created, not-yet-saved, document types.
146: */
147: long getLastModifier();
148:
149: DocumentTypeDocument getXml();
150:
151: /**
152: * Same as {@link #getXml()} but includes the full XML description of the associated
153: * part types and field types in the generated XML.
154: */
155: DocumentTypeDocument getExtendedXml();
156:
157: void setAllFromXml(DocumentTypeDocument.DocumentType documentTypeXml);
158:
159: void save() throws RepositoryException;
160:
161: long getUpdateCount();
162: }
|