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.ValueType;
019: import org.outerj.daisy.repository.RepositoryException;
020: import org.outerj.daisy.repository.query.SortOrder;
021: import org.outerx.daisy.x10.FieldTypeDocument;
022: import org.outerx.daisy.x10.ExpSelectionListDocument;
023:
024: import java.util.Date;
025: import java.util.Locale;
026:
027: /**
028: * Describes a type of field in the repository.
029: *
030: * <p>Instances are retrieved from {@link RepositorySchema}.
031: *
032: * <p>The equals method for FieldType is supported, two field types are
033: * equal if all their defining data is equal, with exception of the ID.
034: */
035: public interface FieldType extends DescriptionEnabled, LabelEnabled {
036: long getId();
037:
038: ValueType getValueType();
039:
040: String getName();
041:
042: void setName(String name);
043:
044: boolean isDeprecated();
045:
046: void setDeprecated(boolean deprecated);
047:
048: int getSize();
049:
050: /**
051: * Sets the size of this FieldType. If this method isn't called,
052: * the size will be 0. The size can be used for presentational purposes,
053: * and doesn't cause any validation to happen.
054: */
055: void setSize(int size);
056:
057: /**
058: * Indicates whether fields of this type can be used in object expressions of ACL rules.
059: * When fields can be used in ACL object expressions, this means that changing the
060: * value of such as field can influence the result of the ACL.
061: */
062: boolean isAclAllowed();
063:
064: void setAclAllowed(boolean aclAllowed);
065:
066: boolean isMultiValue();
067:
068: boolean isHierarchical();
069:
070: /**
071: * Returns true if the values of fields of this field type are simple objects,
072: * rather than more complex objects, which is the case for multivalue and/or
073: * hierarchical fields.
074: *
075: * <p>So this is basically the same as: !isMultiValue() && !isHierarhical(),
076: * but is safe for the case other dimensions would be added in the future.
077: */
078: boolean isPrimitive();
079:
080: /**
081: * When was this PartType last changed (persistently). Returns null on newly
082: * created FieldTypes.
083: */
084: Date getLastModified();
085:
086: /**
087: * Who (which user) last changed this PartType (persistently). Returns -1 on
088: * newly created FieldTypes.
089: */
090: long getLastModifier();
091:
092: /**
093: * Clears(removes) the SelectionList for this FieldType.
094: */
095: void clearSelectionList();
096:
097: /**
098: * Returns the SelectionList for this FieldType if one has been defined,
099: * null if no SelectionList had been defined (i.e. not set for this FieldType
100: * using the setSelectionList(SelectionList selectionList) method).
101: */
102: SelectionList getSelectionList();
103:
104: boolean hasSelectionList();
105:
106: /**
107: * Creates and returns a StaticSelectionList. The selection list automatically
108: * becomse the selection list of this field type.
109: */
110: StaticSelectionList createStaticSelectionList();
111:
112: /**
113: * Creates and returns a LinkQuerySelectionList. The selection list automatically
114: * becomse the selection list of this field type.
115: *
116: * <p>This only works for link-type fields.
117: */
118: LinkQuerySelectionList createLinkQuerySelectionList(
119: String whereClause, boolean filterVariants);
120:
121: /**
122: * Creates and returns a QuerySelectionList. The selection list automatically
123: * becomse the selection list of this field type.
124: */
125: QuerySelectionList createQuerySelectionList(String query,
126: boolean filterVariants, SortOrder sortOrder);
127:
128: HierarchicalQuerySelectionList createHierarchicalQuerySelectionList(
129: String whereClause, String[] fieldTypeNames,
130: boolean filterVariants);
131:
132: ParentLinkedSelectionList createParentLinkedSelectionList(
133: String whereClause, String linkFieldName,
134: boolean filterVariants);
135:
136: boolean getAllowFreeEntry();
137:
138: /**
139: * When a field type has a selection list, should the user also be able to
140: * enter other values then those available in the selection list?
141: *
142: * <p>Note that in either case, it is not checked whether the fields' value
143: * occurs in the selection list. This is only a hint towards the editing GUI.
144: */
145: void setAllowFreeEntry(boolean allowFreeEntry);
146:
147: boolean getLoadSelectionListAsync();
148:
149: void setLoadSelectionListAsync(boolean loadAsync);
150:
151: /**
152: * Returns the content of the selection list as XML. Returns null if there is
153: * no selection list.
154: */
155: ExpSelectionListDocument getExpandedSelectionListXml(long branchId,
156: long languageId, Locale locale);
157:
158: FieldTypeDocument getXml();
159:
160: void setAllFromXml(FieldTypeDocument.FieldType fieldTypeXml);
161:
162: void save() throws RepositoryException;
163:
164: long getUpdateCount();
165: }
|