EnterMedia Event Management System

EnterMedia contains an advanced event system. With the EnterMedia events system you can:

  • Run events at anytime with the event user interface.
  • Schedule an event to run in the future.
  • Create your own events, which is especially good for manipulating large amounts of data.

The best way to demonstrate events is give an example. For this example I will be creating a new event which will go through all of the items in the photo catalog, if the item contains the word 'portrait' in the title it will rotate the image 90 degrees.

  1. Add a .xconf file to the catalog's "events" folder. For this example I called my file "autorotate.xconf". The .xconf file defines the actions the event should perform. In this case my event will be running a script called autorotate.bsh. You can also have your event run path actions or page actions. Here is the text for "autorotate.xconf":
    <page>
    <property name="virtual">true</property>
    <path-action name="Script.run" allowduplicates="true">
    <script>/${catalogid}/events/scripts/autorotate.bsh</script>
    </path-action>
    </page>
  2. Now for the hard part: writing the script. The following bit of code will iterate over all assets in a catalog, if you only want certain items in a catalog you can modify the searcher to fit your needs.  This code goes into the script file specified by the .xconf in step 1.
    import org.openedit.data.Searcher;
    import com.openedit.hittracker.SearchQuery;
    import com.openedit.hittracker.HitTracker;
    
    public void init()
    {
    	catalogid = context.getPageValue("catalogid");
    	log.info("Auto rotating assets in " + catalogid);
    	mediaArchive = context.getPageValue("mediaarchive");
    	int count = 0;
    	
    	//load xml file that contains what libraries have special permissions
    	searcherManager = mediaArchive.getSearcherManager();
    	
    	//search for all of the assets in the catalog
    	Searcher targetsearcher = mediaarchive.getAssetSearcher();
    	SearchQuery q = targetsearcher.createSearchQuery();
    	q.addMatches("category", "index");
    	
    	HitTracker hits = targetsearcher.search(q);
    	
    	//loop through every asset in the catalog
    	for (Iterator iterator = hits.iterator(); iterator.hasNext();)
    	{
    		hit = iterator.next();
    	}
    }
    
    init();
    
    In this case I only want the assets that contain 'portrait' in the title so I change:
    q.addMatches("category", "index");
    
    to:
    q.addMatches("assettitle", "portrait");
    
    Next, inside of the FOR loop we need to load the asset object and set it's rotation. Which is accomplished with the following code:
    //load the asset
    asset = mediaArchive.getAssetBySourcePath(hit.get("sourcepath"));
    //set the rotation 8 is the value for 90 degrees see
    asset.set("imageorientation", "8");
    
  3. Finally, the fun part: running the script. Go to the events page and click the run link for our new auto rotate event. If the auto rotate event does not show up click the "Reload List and Restart" link.
  4. You can schedule your event to run automatically at a specified interval by clicking the "edit" link for your event.  Period and delay values are in milliseconds. (e.g. 3600000 = 1 hour).  The event must be "enabled" to run automatically