MetadataManager metadataManager = Connector.getMetadataManager(); // Create metadata template and metadata labels. // Now create a metadata template hierarchy. // First get the root template UUID. The root template provides an optional // root for the template hierarchy for a specific organization. // Other templates don't have to inherit from the root template, but it's // a good convention. Templates that don't inherit from the root template // won't show up in the Administrator application. // If the root template does not exist, the system will create a new // metadata template using the default name: "Default Metadata Template". String rootTemplateUuid = metadataManager.getRootMetadataTemplateUuid(m_userAuth, m_userAuth.getOrgUuid()); // Create a new template, called "Design Drawings". String designDrawingsTemplateUuid = metadataManager.createTemplate(m_userAuth, "Design Drawings Template", m_userAuth.getOrgUuid()); cleanupTemplateUuids.add(designDrawingsTemplateUuid); // Create another new template, called "Finance". String financeTemplateUuid = metadataManager.createTemplate(m_userAuth, "Finance Template", m_userAuth.getOrgUuid()); cleanupTemplateUuids.add(financeTemplateUuid); // Make the new templates children of the root template. // The child templates now inherit the "Author" label from the root template. try { metadataManager.addChildTemplate(m_userAuth, rootTemplateUuid, designDrawingsTemplateUuid); metadataManager.addChildTemplate(m_userAuth, rootTemplateUuid, financeTemplateUuid); } catch(DuplicateNameException ex) { // Duplicate names are not allowed in child templates, // therefore you would get this exception when you run this // program more than once. Here we ignore the exception. System.out.println("Duplicate Template Exception"); } // Add a "Design Status" label to the "Design Drawing" template. String statusLabelUuid = metadataManager.createMetadataLabelInTemplate(m_userAuth, designDrawingsTemplateUuid, "Design Status", // the 'Key' true, // required DataType.PICKONE, // a PickOne enumerated type null, // default value null); // max length // Create selections (enumerated values) for the "Design Status" PICKONE label. String inProgressSelectionUuid = metadataManager.createMetadataSelection(m_userAuth, statusLabelUuid, DataType.STRING, "In Progress", null ); String inRevisionSelectionUuid = metadataManager.createMetadataSelection(m_userAuth, statusLabelUuid, DataType.STRING, "In Revision", null ); String acceptedSelectionUuid = metadataManager.createMetadataSelection(m_userAuth, statusLabelUuid, DataType.STRING, "Accepted", null ); String rejectedSelectionUuid = metadataManager.createMetadataSelection(m_userAuth, statusLabelUuid, DataType.STRING, "Rejected", null ); // Create another label, called "Hours Worked", for the number of hours that have been spent on // this drawing. String hoursWorkedLabelUuid = metadataManager.createMetadataLabelInTemplate(m_userAuth, designDrawingsTemplateUuid, "Hours Worked", false, DataType.NUMBER, null, // default value null); // max length // Create a "cost" label in the "Finance" template. String costLabelUuid = metadataManager.createMetadataLabelInTemplate(m_userAuth, financeTemplateUuid, "cost", true, // required DataType.NUMBER, null, // default value null); // max length