public IDAttribute(Entity container, String name)
throws IllegalActionException, NameDuplicationException {
super(container, name);
// name for the model
this.name = new StringAttribute(this, "name");
this.name.setExpression(container.getName());
// This should not be persistent, in case the name changes outside
// of this parameter.
this.name.setPersistent(false);
// This should not be editable, since the name is set by saveAs.
this.name.setVisibility(Settable.NOT_EDITABLE);
// FIXME: Need to listen for changes to the name.
// How to do that?
// The current design is also a solution in that the name of this
// attribute and model must be consistent with the name of the file.
// boolean isClass = false;
//if (container instanceof InstantiableNamedObj) {
/* isClass = */((InstantiableNamedObj) container).isClassDefinition();
//}
String className = container.getClassName();
baseClass = new StringAttribute(this, "baseClass");
baseClass.setExpression(className);
// This should not be persistent, because the base class
// is set already, generally.
baseClass.setPersistent(false);
// Cannot change the base class.
baseClass.setVisibility(Settable.NOT_EDITABLE);
URIAttribute modelURI = (URIAttribute) container.getAttribute("_uri",
URIAttribute.class);
if (modelURI != null) {
StringAttribute definedIn = new StringAttribute(this, "definedIn");
definedIn.setExpression(modelURI.getURI().toString());
definedIn.setPersistent(false);
definedIn.setVisibility(Settable.NOT_EDITABLE);
}
// The date when this model is created.
// Actually, it is the date when this attribute is created.
// We assume that when the model is created, this attribute
// is also created.
// We may force this to happen.:-) Further more, we may force
// that only the top level contains an model ID.
created = new StringAttribute(this, "created");
created.setExpression(DateFormat.getDateTimeInstance().format(
new Date()));
created.setVisibility(Settable.NOT_EDITABLE);
created.setPersistent(true);
// The date when this model is modified.
// Everytime the model gets modified, the updateContent method
// defined below is called and the lastUpdated attribute gets
// updated.
lastUpdated = new StringAttribute(this, "lastUpdated");
_updateDate();
lastUpdated.setVisibility(Settable.NOT_EDITABLE);
lastUpdated.setPersistent(true);
// The name of the author who creates the model.
// This attribute can not be changed so that the
// intellectual property (IP) is preserved.
author = new StringAttribute(this, "author");
author.setVisibility(Settable.NOT_EDITABLE);
String userName = null;
try {
userName = StringUtilities.getProperty("user.name");
} catch (Exception ex) {
System.out.println("Warning, in IDAttribute, failed to read "
+ "'user.name' property (-sandbox or applets always cause "
+ "this)");
}
if (userName != null) {
author.setExpression(userName);
}
author.setPersistent(true);
// The names of the contributors who modify the model.
contributors = new StringAttribute(this, "contributors");
String contributorsNames = "";
contributors.setExpression(contributorsNames);
author.setPersistent(true);