7.5.1. Custom Folder Structures

Engineering Knowledge Manager

Administration Guide | Chapter 7: Defining Custom Types | 7.5. Custom Type Examples |

7.5. Custom Type Examples |  | 7.5.2. Custom Analysis Projects
Prev |  | Next

### 7.5.1. Custom Folder Structures

You can define a custom folder structure to control how your data is organized in EKM. It can provide a standard way of naming and organizing files and folders. Custom folder structure data types specify the name, type, and occurrence (single or multiple) of child objects and enable you to control how new objects are added to a particular type. All custom folders should extend the `Container` type, or a subtype of `Container`.

Let's look at how you can define a custom folder structure by means of an example.

Suppose you want all of your simulation projects to be stored in a common place in EKM, and you want each project to organize the data in three folders: Requirements, Common Files, and Reports. Let's say you also want users to create new folders for each simulation they perform for the project, and furthermore, you want users to enter some required attributes when they start a new project.

The first step in the process is to define a new type named `ProjectContainer` (Example 7.7: Defining a Project Container Type). It will appear in the user interface as Project Container (its localized name) with version `1.0.0`. It extends the built-in `Container` type. The listing below shows the XML code fragment.

Example 7.7: Defining a Project Container Type

    <type name="ProjectContainer" extends="Container" label="Project Container" version="1.0.0">
           <children>
              <child name="" occurs="list" type="Project"/>
           </children>
    </type>

The `ProjectContainer` type can only have children of type `Project`, where `Project` is another custom type that we will define shortly. The `occurs` attribute of the `child` element dictates whether a single instance or multiple instances of the child type are allowed. In this case, occurs is set to `list` which means that multiple instances of `Project` type can be added to a `ProjectContainer`. The other valid values for `occurs` are `required` and `optional`. The `required` value is used if only one instance of the child is allowed, and this instance must always exist. The `optional` value is used if the child may or may not exist. For custom types, you should only use `required` or `list` values.

The `name` attribute specifies the name of the child. It is ignored and can be set to an empty string if `occurs` is set to `list`. If `occurs` is set to `required` then the child will be automatically created when the parent object is created. You therefore need to provide a valid `name` for the child. The child name cannot contain the following special characters:

`/ \ : [ ] % * ' " | > < ?`

Now that we have created the `Project Container` type, we will define a new `Project` type. The XML code listing shown in Example 7.8: Defining a Project Type is for a new `Project` type. It extends the built-in type `Container` and defines some required user-defined properties: `componentType`, `disciplines`, `partId`, `exportControlled` and `dateOfIssue`. The user who creates a project in EKM by will be prompted to enter values for these properties. This type also has some required children: `Requirements`, `CommonFiles` and `Reports` that are all of type `Folder`. When a `Project` instance is created, these required children are also created automatically at the same time. You cannot delete a required `child`. The `Project` type also enables you to create more instances of `Folder` type for the various simulations to be performed in the project. Some custom actions are also specified for the `Project` type. These were explained in the previous section.

In EKM you can use the New > Folder action menu in any folder to create an instance of a custom folder that is allowed in the parent folder. If there are any required user-defined properties associated with the type, you will be prompted to enter their values at the time of object creation in the New Folder dialog box. All of the necessary user interface components will be automatically generated by EKM.

Example 7.8: Defining a Project Type

    <type name="Project" extends="Container" version="1.0.0">
            <properties>
                <property name="componentType" label="Component Type" type="String"
    required="true">
                    <enumeration>Type A</enumeration>
                    <enumeration>Type B</enumeration>
                    <enumeration>Type C</enumeration>
                </property>
                <property name="disciplines" label="Disciplines" type="String"
    required="true" multivalued="true">
                    <enumeration>Stress</enumeration>
                    <enumeration>Flow</enumeration>
                    <enumeration>Thermal</enumeration>
                    <enumeration>Electromagnetic</enumeration>
                </property>
                <property name="partId" label="Part Id" type="Long" required="true">
                	<constraint name="min" value="0" />
                	<constraint name="max" value="100" />
                </property>
                <property name="exportControlled" label="Export Controlled?"
    type="Boolean" required="true"/>
                <property name="dateOfIssue" label="Date Of Issue" type="Date" required="true"/>
            </properties>
            <children>
            	<child name="Requirements" occurs="required" type="Folder"/>
            	<child name="Common Files" occurs="required" type="Folder"/>
            	<child name="" occurs="list" type="Folder"/>
            	<child name="Reports" occurs="required" type="Folder"/>
            </children>
            <actions>
            	<script>
            		appendDescription(object, dialog) {
            			description = object.getProperty("description");
            			ekm.startTransaction();
            			time = Calendar.getInstance().getTime().toString();
            			object.setProperty("description", description+", added at: "+time);
            			ekm.commitTransaction();
            		}
            		setDescription(dialog) {
            			ekm.startTransaction();
            			object = dialog.getObject();
            			object.setProperty("description", dialog.getVars().get("description").getValue());
            			ekm.commitTransaction();
            		}
            		setDescriptionDialog(object, dialog) {
      					dialog.addStep("Set Description",
                                  "/custom/set-project-description/set-description.xhtml",
      						"setDescription");
            			description = object.getProperty("description");
            			dialog.addVar("description", dialog.VARIABLE_TYPE_STRING, description, false);
            		}
            	</script>
            	<action name="Custom Actions/Append Description" macro="appendDescription"
    permissions=" modify"/>
            	<action name="Custom Actions/Set Description" macro="setDescriptionDialog"
    permissions=" modify"/>
            </actions>
    </type>

Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates.

Prev | Up / Contents | Next

Release 18.2 - © ANSYS, Inc. All rights reserved.