Skip to content

Commit

Permalink
Improved entity creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tHerrmann committed Jan 24, 2012
1 parent d695e97 commit b258e57
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/com/alkacon/vie/client/Vie.java
Expand Up @@ -94,11 +94,20 @@ public native void bindFunctionToEntities(String functionName, I_EntityCallback
* @return the new entity
*/
public native I_Entity createEntity(String entityId, String entityType) /*-{
var properties = {
'@subject' : entityId,
'@type' : entityType
};
var entityInstance = new this.Entity(properties);
var entityType = this.types.get(entityType);
var entityInstance;
if (entityType != null) {
// if the type is available, use it to create the new instance
entityInstance = entityType.instance({
'@subject' : entityId
});
} else {
// otherwise create a new entity
entityInstance = new this.Entity({
'@subject' : entityId,
'@type' : entityType
});
}
return this.entities.addOrUpdate(entityInstance);
}-*/;

Expand Down

0 comments on commit b258e57

Please sign in to comment.