The default TLcdEditableAPP6AObject
or TLcdEditableMS2525bObject
objects implement ILcdDataObject
with the
TLcdAPP6ADataTypes.APP6AObjectType
and
TLcdMS2525bDataTypes.MS2525bObjectType
data types respectively.
When your domain objects contain properties that are not defined in those data types, you can extend those data types, so
they contain your additional properties.
You can extend those types by creating your own TLcdDataType
and passing either
TLcdAPP6ADataTypes.APP6AObjectType
or
TLcdMS2525bDataTypes.MS2525bObjectType
to
TLcdDataTypeBuilder.superType(TLcdDataType)
.
You then have to extend TLcdEditableAPP6AObject
or TLcdEditableMS2525bObject
and override all ILcdDataObject
methods, so they use your own extended data types
Here is an example of a class that creates a data type which extends the TLcdAPP6ADataTypes.APP6AObjectType
,
by adding a custom property to it and overrides all ILcDataObject
methods of TLcdEditableAPP6AObject
.
import com.luciad.datamodel.TLcdCoreDataTypes;
import com.luciad.datamodel.TLcdDataModel;
import com.luciad.datamodel.TLcdDataModelBuilder;
import com.luciad.datamodel.TLcdDataObject;
import com.luciad.datamodel.TLcdDataProperty;
import com.luciad.datamodel.TLcdDataType;
import com.luciad.datamodel.TLcdDataTypeBuilder;
import com.luciad.symbology.app6a.model.TLcdAPP6ADataTypes;
import com.luciad.symbology.app6a.model.TLcdEditableAPP6AObject;
public class ExtendedAPP6AObject extends TLcdEditableAPP6AObject {
public static TLcdDataModel EXTENDED_MODEL;
public static TLcdDataType EXTENDED_TYPE;
static {
// Create the builder for the data model.
// Use some unique name space, to prevent name clashes. This isn't really needed
// for the sample but might be useful when exposing it externally.
TLcdDataModelBuilder builder = new TLcdDataModelBuilder(
"http://www.mydomain.com/datamodel/ExtendedAPP6AModel");
// Create a new type called 'ExtendedAPP6AType' which extends from the APP6 data type
TLcdDataTypeBuilder dataType = builder.typeBuilder("ExtendedAPP6AType")
.superType(TLcdAPP6ADataTypes.APP6AObjectType);
// Add a String property called 'MyProperty' to 'ExtendedAPP6AType'
dataType.addProperty("MyProperty", TLcdCoreDataTypes.STRING_TYPE);
// create the data model
EXTENDED_MODEL = builder.createDataModel();
// extract the extended data type
EXTENDED_TYPE = EXTENDED_MODEL.getDeclaredType("ExtendedAPP6AType");
}
// Create a delegate data object based on the extended data type
// all ILcdDataObject methods will be delegated to this object
private TLcdDataObject fDelegate = new TLcdDataObject(EXTENDED_TYPE);
@Override
public TLcdDataType getDataType() {
return fDelegate.getDataType();
}
@Override
public Object getValue(TLcdDataProperty aProperty) {
if (fDelegate.getDataType().getDeclaredProperty(aProperty.getName()) != null) {
return fDelegate.getValue(aProperty);
} else {
// delegate properties not declared by our extended data type to the super class
// to make sure not to override military symbology specific behaviour
return super.getValue(aProperty);
}
}
@Override
public Object getValue(String aPropertyName) {
if (fDelegate.getDataType().getDeclaredProperty(aPropertyName) != null) {
return fDelegate.getValue(aPropertyName);
} else {
// delegate properties not declared by our extended data type to the super class
// to make sure not to override military symbology specific behaviour
return super.getValue(aPropertyName);
}
}
@Override
public void setValue(TLcdDataProperty aProperty, Object aValue) {
if (fDelegate.getDataType().getDeclaredProperty(aProperty.getName()) != null) {
fDelegate.setValue(aProperty, aValue);
} else {
// delegate properties not declared by our extended data type to the super class
// to make sure not to override military symbology specific behaviour
super.setValue(aProperty, aValue);
}
}
@Override
public void setValue(String aPropertyName, Object aValue) {
if (fDelegate.getDataType().getDeclaredProperty(aPropertyName) != null) {
fDelegate.setValue(aPropertyName, aValue);
} else {
// delegate properties not declared by our extended data type to the super class
// to make sure not to override military symbology specific behaviour
super.setValue(aPropertyName, aValue);
}
}
@Override
public boolean hasValue(TLcdDataProperty aProperty) {
if (!fDelegate.hasValue(aProperty)) {
// delegate properties with no value in our data type by our extended data type to the super class
// to make sure not to override military symbology specific behaviour
return super.hasValue(aProperty);
}
return true;
}
@Override
public boolean hasValue(String aPropertyName) {
if (!fDelegate.hasValue(aPropertyName)) {
// delegate properties not declared by our extended data type to the super class
// to make sure not to override military symbology specific behaviour
return super.hasValue(aPropertyName);
}
return true;
}
}