theriom.com
This blog is mainly for me, a way of remembering things I've done; when I couldn't find an answer on Google, I wrote about it here. Hopefully, other people may find it helpful too.
Oracle Data Modeler Transformation Framework

Data Modeler has a powerful javascript engine to programatically view and change items within the model. Below is a simple framework for processing the logical model.

// Get all // entities = model.getEntitySet().toArray();

                                // or ... limit to one subview.
entities = model.getSubViewByName("subviewname").getEntities();

processEntities(entities);

/*
	Process the selected entities
*/
function processEntities(entities)
{
	for(var a=0; a < entities.length; a++)
	{
        processEntity(entities[a]);
	}
}

/*
	Process an entity
*/
function processEntity(entity)
{								// Get the entity's name.
	name = entity.getName();

                                // If you change something, set the dirty flag
	entity.setDirty(true);

                                // Iterate through it's attributes
	attributes = entity.getAttributes();
	for(var b=0; b < attributes.length; b++)
	{
        processAttributes(entity, attributes[b]);
	}
}

/*
	Process an Attribute
*/
function processAttributes(entity, attribute)
{
                                // Get the entity's name.
	name = attribute.getName();

                                // If you change something, set the dirty flag
	attribute.setDirty(true);
}

/*
	Display a message
*/
function alert(message)
{
	javax.swing.JOptionPane.showMessageDialog(null, message);
}

/*
    Add a change to the notes field
*/
function prependNotes(item, prependString)
{
	var d = new Date();

	var currentDate =  d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate();

	currentNote = item.getNotes();

	var versionNotes = "[" + currentDate + ":" + prependString + "]\n";

	item.setNotes(versionNotes + currentNote);
}

Last modified on 2016-03-20