Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskSchema.java26
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/DefaultTaskSchemaTest.java21
2 files changed, 42 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskSchema.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskSchema.java
index dc8a9df9b..944749aa0 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskSchema.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskSchema.java
@@ -24,7 +24,7 @@ import org.eclipse.core.runtime.Assert;
/**
* Base class for task schemas. Clients should subclass to define a specific schema.
- *
+ *
* @author Steffen Pingel
* @author David Green
* @author Miles Parker
@@ -90,6 +90,7 @@ public abstract class AbstractTaskSchema {
metaData.setType(getType());
metaData.setReadOnly(isReadOnly());
metaData.setKind(getKind());
+ metaData.setRequired(isRequired());
// options
Map<String, String> options = getDefaultOptions();
if (options != null) {
@@ -110,7 +111,7 @@ public abstract class AbstractTaskSchema {
/**
* the key to use when indexing this field
- *
+ *
* @return the index key, or null if this should not be indexed
* @since 3.7
*/
@@ -192,17 +193,32 @@ public abstract class AbstractTaskSchema {
return true;
}
+ /**
+ * @since 3.11
+ */
+ public boolean isRequired() {
+ return flags.contains(Flag.REQUIRED);
+ }
+
}
public enum Flag {
ATTRIBUTE, OPERATION, PEOPLE, READ_ONLY,
/**
* A flag used to indicate that the field is related to a description.
- *
+ *
* @since 3.11
* @see TaskAttribute#KIND_DESCRIPTION
*/
- DESCRIPTION
+ DESCRIPTION,
+ /**
+ * A flag used to indicate that the field is required.
+ *
+ * @since 3.11
+ * @see TaskAttribute#META_REQUIRED
+ */
+ REQUIRED
+
};
protected class FieldFactory {
@@ -279,7 +295,7 @@ public abstract class AbstractTaskSchema {
/**
* Provides an iterator for all fields within the schema. Subsequent modifications to the returned collection are
* not reflected to schema.
- *
+ *
* @since 3.9
* @return all fields within the schema
*/
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/DefaultTaskSchemaTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/DefaultTaskSchemaTest.java
index 791095220..de3b77105 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/DefaultTaskSchemaTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/DefaultTaskSchemaTest.java
@@ -39,6 +39,8 @@ public class DefaultTaskSchemaTest extends TestCase {
public final Field SUMMARY_READ_ONLY = inheritFrom(parent.SUMMARY).addFlags(Flag.READ_ONLY).create();
+ public final Field PRODUCT_REQUIRED = inheritFrom(parent.PRODUCT).addFlags(Flag.REQUIRED).create();
+
public final Field REPORTER = inheritFrom(parent.USER_REPORTER).create();
public final Field REPORTER_MODIFIED = inheritFrom(parent.USER_REPORTER).addFlags(Flag.READ_ONLY)
@@ -97,4 +99,23 @@ public class DefaultTaskSchemaTest extends TestCase {
public void testDescriptionHasKind() {
assertEquals(TaskAttribute.KIND_DESCRIPTION, DefaultTaskSchema.getInstance().DESCRIPTION.getKind());
}
+
+ public void testRequiredAttribute() {
+ TestSchema schema = new TestSchema();
+ assertEquals(TaskAttribute.PRODUCT, schema.PRODUCT_REQUIRED.getKey());
+ TaskData testData = new TaskData(new TaskAttributeMapper(new TaskRepository("mock", "http://mock")), "mock",
+ "http://mock", "-1");
+ schema.initialize(testData);
+ assertNotNull(testData.getRoot().getAttribute(TaskAttribute.USER_REPORTER));
+ assertFalse("USER_REPORTER should be not required", testData.getRoot()
+ .getAttribute(TaskAttribute.USER_REPORTER)
+ .getMetaData()
+ .isRequired());
+ assertNotNull(testData.getRoot().getAttribute(TaskAttribute.PRODUCT));
+ assertTrue("PRODUCT should be required", testData.getRoot()
+ .getAttribute(TaskAttribute.PRODUCT)
+ .getMetaData()
+ .isRequired());
+ }
+
}

Back to the top