The Web Graph Database

wiki:Docs/ChangingProperty

Changing a the value of a MeshObject's Property

Assume that the following MeshObject is already blessed with EntityType org.infogrid.model.Wiki/WikiObject, and that the Property org.infogrid.model.Wiki/WikiObject_Content needs to be set to new value "update succeeded".

A Transaction is necessary to create, delete or update any MeshObject.

The PropertyType org.infogrid.model.Wiki/WikiObject_Content defines a BlobDataType as the DataType. This means that a BlobValue instance needs to be used as the new value of the Property. BlobValues must be created by using their BlobDataType as a factory. (Other PropertyValues can be created with static factory methods in their classes.)

To update the Property of the MeshObject:

MeshBase    mb = obj.getMeshObject();
Transaction tx = null;
try {
    tx = mb.createTransactionAsap();

    obj.setPropertyValue( // setting the new value
            WikiSubjectArea.WIKIOBJECT_CONTENT,
            WikiSubjectArea.WIKIOBJECT_CONTENT_type.createBlobValue( "<p>update succeeded</p>", "text/html" ));

} finally {
    if( tx != null ) {
        tx.commitTransaction();
    }
}

Alternatively, the TypedMeshObjectFacade may be used:

First the TypedMeshObjectFacade of the MeshObject is determined for the correct EntityType, and downcast to the corresponding interface generated by the CodeGenerator. Then, the generated JavaBeans property setter method can be invoked:

MeshBase    mb = obj.getMeshObject();
Transaction tx = null;
try {
    tx = mb.createTransactionAsap();

    WikiObject  facade = (WikiObject) obj.getTypedMeshObjectFacade(); // could also be outside of the Transaction
    facade.setContent( // setting the new value
            WikiSubjectArea.WIKIOBJECT_CONTENT_type.createBlobValue( "<p>update succeeded</p>", "text/html" ));

} finally {
    if( tx != null ) {
        tx.commitTransaction();
    }
}
Last modified 5 years ago Last modified on 07/24/09 16:38:23