Skip to end of metadata
Go to start of metadata

You have created (too) many Sub Classes under Root to hold your Material Definitions
Because of a versioning mechanism, this is now considerably slowing down editing any Material even though the Classes
or Sub Classes are holding only the recommended 20 Materials / Class

This script is meant to resolve a performance problem seen in MES 2.0

caution: it is not advised to start any new runs during the Script execution time.

Step-by-step guide

This Script will move all classes to be under the root while still retaining a similar name to the previous path.

This does leave some empty classes.

All the names were able to fit the existing name limit. 

  1. It is recommended to execute this Script in a Gateway Script on Tag Change for example to avoid Time Out 
    if executed in the Script Console
    as always : backup your GW and your MES DB and/or test on a copy of your Production

    mes_filter = system.mes.object.filter.createFilter()
    material_classes = system.mes.loadMESObjects(mes_filter)
    material_root = system.mes.loadMESObjects(mes_filter).get(0)
    save_list = system.mes.object.list.createList()
    materials = {}
    for material_class in material_classes:
    	materials[material_class.getUUID()] = material_class
    sep = '-'
    def flatten_name(obj):
    	parent = obj.getParentCollection().getList().get(0)
    	if parent.getMESObjectUUID() != material_root.getUUID():
    		print materials[parent.getMESObjectUUID()]
    		prefix = flatten_name(materials[parent.getMESObjectUUID()])
    		name = obj.getName()
    		if prefix != '':
    			name = prefix + sep + name
    		return  name
    		return ''
    for material_class in material_classes:
    	parents = material_class.getParentCollection()
    	if parents.size() == 1:
    		parent = parents.getList().get(0)
    		if parent.getMESObjectUUID() != material_root.getUUID():
    			material_class.setPropertyValue('Name', flatten_name(material_class))

Copy Material Definition(s) from a (root) Class to a Sub Class of that (root) Class

OEE Material Manager