X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fentity%2Fadapter%2FEntityAdapterDefinition.java;h=9c95ab37998173ce86d216b6aabbe6968033f8ad;hb=97488204d3bc9d251b525a70b2cf0c70956a3484;hp=bb132a52885403322c59d0a0e63dbcd55a7757ca;hpb=3beba5fd39a5d60ba5b87064ddf11dea30b78413;p=mir.git
diff --git a/source/mir/entity/adapter/EntityAdapterDefinition.java b/source/mir/entity/adapter/EntityAdapterDefinition.java
index bb132a52..9c95ab37 100755
--- a/source/mir/entity/adapter/EntityAdapterDefinition.java
+++ b/source/mir/entity/adapter/EntityAdapterDefinition.java
@@ -32,45 +32,96 @@ package mir.entity.adapter;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
-import java.util.*;
+import java.util.HashMap;
import java.util.Map;
+import java.util.TimeZone;
import mir.entity.Entity;
+import mir.misc.StringUtil;
import mir.util.GeneratorFormatAdapters;
-import mir.misc.*;
+/**
+ * EntityAdapterDefinition
defines the fields for an entity adapter of
+ * a particular "type". Custom calculated fields can be defined.
+ *
+ */
public class EntityAdapterDefinition {
- Map calculatedFields;
+ private Map calculatedFields;
public EntityAdapterDefinition() {
calculatedFields = new HashMap();
}
+ /**
+ *
+ *
+ * @param anEntity the entity that will be wrapped by the entity adapter
+ * @param aModel the base model
+ * @return the resulting entity adapter
+ */
public EntityAdapter makeEntityAdapter(Entity anEntity, EntityAdapterModel aModel) {
return new EntityAdapter(anEntity, this, aModel);
}
+ /**
+ *
+ * @param aFieldName
+ * @return the CalculatedField
if it exists. null
otherwise
+ */
public CalculatedField getCalculatedField(String aFieldName) {
return (CalculatedField) calculatedFields.get(aFieldName);
}
+ /**
+ *
+ * @param aFieldName
+ * @return boolean true if aFieldName is a calculated Field
+ */
public boolean hasCalculatedField(String aFieldName) {
return calculatedFields.containsKey(aFieldName);
}
+ /**
+ *
+ * @param aFieldName
+ * @param aField
+ */
public void addCalculatedField(String aFieldName, CalculatedField aField) {
calculatedFields.put(aFieldName, aField);
}
+ /**
+ * To add a calculated field based on a "mir" date field: a string field of the form yyyyMMdd[hhmm]
+ *
+ * @param aDestinationFieldName
+ * @param aSourceFieldName
+ * @param aDefaultTimezone
+ */
public void addMirDateField(String aDestinationFieldName, String aSourceFieldName, String aDefaultTimezone) {
addCalculatedField(aDestinationFieldName, new MirDateField(aSourceFieldName, aDefaultTimezone));
}
+ /**
+ * Adds a calculated field based on a db date field
+ *
+ * @param aDestinationFieldName the field name of the calculated field
+ * @param aSourceFieldName the field name of the entity (must be a date field)
+ * @param aDefaultTimezone the default timezone to use
+ */
public void addDBDateField(String aDestinationFieldName, String aSourceFieldName, String aDefaultTimezone) {
addCalculatedField(aDestinationFieldName, new DBDateField(aSourceFieldName, aDefaultTimezone));
}
+ /**
+ * a calculated field: field gets its value from other fields.
+ */
public interface CalculatedField {
+ /**
+ * Method to retrieve the calculated value of the field.
+ *
+ * @param anEntityAdapter the entity
+ * @return the value of the field.
+ */
public Object getValue(EntityAdapter anEntityAdapter);
}
@@ -86,7 +137,7 @@ public class EntityAdapterDefinition {
public Object getValue(EntityAdapter anEntityAdapter) {
Object result = null;
- String textValue = anEntityAdapter.getEntity().getValue(fieldName);
+ String textValue = anEntityAdapter.getEntity().getFieldValue(fieldName);
Calendar calendar = GregorianCalendar.getInstance();
int year;
int month;
@@ -125,7 +176,7 @@ public class EntityAdapterDefinition {
public Object getValue(EntityAdapter anEntityAdapter) {
Object result = null;
- String text = anEntityAdapter.getEntity().getValue(fieldName);
+ String text = anEntityAdapter.getEntity().getFieldValue(fieldName);
if (text!=null) {
try {