Creating attribute collections

You can create the attribute collections so that users are able to easily manage large number of attributes. Attribute Collections are a group of specs and attributes that will behave the same way in all contexts.

Before you begin

Ensure that you know the types of attribute collections that the user would require.
Note: The maximum size of the attribute collection name is 21 characters.

About this task

Users can also model data in an organized and efficient manner by using the attribute collections. When you fetch and save an item category by using the attribute collection, only the attributes selected for a view are retrieved and saved. In this way you can improve performance by using the attribute collections.

Procedure

Create the attribute collection. Use any of the following methods: User interface, Java™ API, or script API.
Option Description
User interface
  1. Click Data Model Manager > Attribute Collections > New Attribute Collection.
  2. Provide a name and description for the attribute collection.
  3. Click Save.
    Note: When you are modifying an attribute collection, for example adding an attribute or spec, or removing an attribute or spec, the changes will be saved before you click Save.
Java API The following sample Java API code creates an attribute collection.
String specName = "Sample Primary Spec";
String acName = "Sample Attribute Collection";
String acDesc = "This is a sample Attribute Collection containing attributes from Sample Primary Spec";

try 
{	
	Spec spec = m_ctx.getSpecManager().getSpec(specName);

	AttributeCollection acSample = m_mgr.createAttributeCollection(acName);
	acSample.save();

	// acSample needs to be saved before adding attributes	acSample.addAllAttributes(spec);
} 
catch ( Exception e) 
{
	e.printStackTrace();
} 
Script API The following sample script API creates an attribute collection.
// The Spec name whose attributes to be added to the new Attribute Collection
var specName = "Sample Primary Spec";
var spec = getSpecByName( specName );

// The description for the new Attribute Collection
var acDesc = "This is a sample Attribute Collection containing attributes from Sample Primary Spec";
// The name for the new Attribute Collection
var acName = "Sample Attribute Collection";

var sampleAC = new AttrGroup( acName, "GENERAL", acDesc);

// boolean: false - static attribute collection;
 true - dynamic attribute collection sampleAC.addSpecToAttrGroup(spec, false);
The attribute collection is created. User can view the new attribute collection in the attribute collection console.