Class EditorUtils


  • public final class EditorUtils
    extends java.lang.Object
    • Method Detail

      • createComboItem

        public static org.zkoss.zul.Comboitem createComboItem​(java.lang.String label,
                                                              java.lang.Object value)
        Creates a combobox item
        Parameters:
        label - Label of item
        value - Value of item
        Returns:
        Combobox item
      • createTreeItem

        public static org.zkoss.zul.Treeitem createTreeItem​(TreeNodeData value,
                                                            boolean expanded)
        Creates a tree item
        Parameters:
        value - Value of tree item
        expanded - Whether node is expanded by default
        Returns:
        Tree item
      • createListItem

        public static org.zkoss.zul.Listitem createListItem​(AbstractListItemDTO dto,
                                                            boolean isComplex,
                                                            boolean hasSubtypes,
                                                            java.util.List<java.lang.String> labels,
                                                            boolean inEditMode,
                                                            ReadService readService)
        Creates a list item
        Parameters:
        dto - DTO containing properties to populate list item
        isComplex - If attribute it a complex type
        hasSubtypes - If attribute has subtypes
        labels - Menuitem labels
        inEditMode - If in edit mode
        Returns:
        A list item
      • createMenuPopup

        public static org.zkoss.zul.Menupopup createMenuPopup​(java.util.List<java.lang.String> labels)
        Create menu popup
        Parameters:
        labels - Labels for menu items
        Returns:
        Menu popup
      • renameTreeitem

        public static org.zkoss.zul.Treeitem renameTreeitem​(org.zkoss.zul.Treeitem treeitem,
                                                            AbstractListItemDTO dto)
        Renames a tree item
        Parameters:
        treeitem - Item to be renamed
        dto - DTO containing relevant rename information
        Returns:
        Newly renamed tree item
      • findInTreechildren

        public static org.zkoss.zul.Treeitem findInTreechildren​(java.lang.String qualifier,
                                                                org.zkoss.zul.Treechildren treechildren)
        Find a matching Treeitem in a given parent Treeitem's Treechildren by qualifier.
        Parameters:
        qualifier - the qualifier to match
        treechildren - the Treechildren to search
        Returns:
        a matching Treeitem, null if not found
      • updateDTOs

        public static java.util.List<AbstractListItemDTO> updateDTOs​(java.util.List<AbstractListItemDTO> oldDTOs,
                                                                     java.util.List<AbstractListItemDTO> newDTOs)
        Updates attributes of a list of DTOs by getting the attributes of another list of DTOs
        Parameters:
        oldDTOs - a list of DTOs with attributes to update
        newDTOs - a list of DTOs containing updated attributes
        Returns:
        a list of DTOs with updated attributes
      • convertIntegrationObjectToDTOMap

        public static java.util.Map<ComposedTypeModel,​java.util.List<AbstractListItemDTO>> convertIntegrationObjectToDTOMap​(ReadService readService,
                                                                                                                                  IntegrationObjectModel integrationObject)
        Converts an integration object's contents to a map of lists of DTOs
        Parameters:
        readService - the ReadService to read from the type system
        integrationObject - an integration object to convert
        Returns:
        a map of lists of DTOs
      • getListItemStructureType

        public static ListItemStructureType getListItemStructureType​(ReadService readService,
                                                                     AttributeDescriptorModel attribute)
        Determines the structure type of the given AttributeDescriptorModel
        Parameters:
        readService - the ReadService to read from the type system
        attribute - the AttributeDescriptorModel to evaluate
        Returns:
        ListItemStructureType enum representing the structure type of the AttributeDescriptorModel
      • getStructuredAttributes

        public static java.util.Set<AttributeDescriptorModel> getStructuredAttributes​(java.util.List<AbstractListItemDTO> dtoList)
        Gets the attribute descriptors of collection and map attributes from a list of DTOs
        Parameters:
        dtoList - a list of AbstractListItemDTO
        Returns:
        a set of AttributeDescriptorModel of CollectionType or MapType attributes
      • getReferenceClassificationAttributes

        public static java.util.Set<TreeNodeData> getReferenceClassificationAttributes​(java.util.List<AbstractListItemDTO> dtoList)
        Builds tree node data for reference type classification attributes
        Parameters:
        dtoList - a list of AbstractListItemDTO
        Returns:
        a set of TreeNodeData for ListItemClassificationAttributeDTO with reference type
      • compileDuplicationMap

        public static java.util.Map<ComposedTypeModel,​java.util.Map<java.lang.String,​java.util.List<AbstractListItemDTO>>> compileDuplicationMap​(ComposedTypeModel currentType,
                                                                                                                                                             java.util.List<AbstractListItemDTO> currentAttributes,
                                                                                                                                                             java.util.Map<ComposedTypeModel,​java.util.Map<java.lang.String,​java.util.List<AbstractListItemDTO>>> duplicationMap)
        Constructs a map with entries of duplicate attribute names associated to list items. These entries are tied to any ComposedTypeModel where a duplicate entry occurs.
        Parameters:
        currentType - Current ComposedType that items were added to.
        currentAttributes - The current list of attributes that have had items added to them
        Returns:
        A map containing any duplicate entries that must be resolved before persisting the IntegrationObject
      • markRowsWithDuplicateNames

        public static boolean markRowsWithDuplicateNames​(java.util.Collection<org.zkoss.zul.Listitem> items,
                                                         java.util.Map<java.lang.String,​java.util.List<AbstractListItemDTO>> duplicateEntries)
        Modifies the sClass of the list items to show highlights on duplicate items.
        Parameters:
        items - List of items to iterate over
        duplicateEntries - Map containing duplicate entries to match with item.
      • isClassificationAttributePresent

        public static boolean isClassificationAttributePresent​(ClassAttributeAssignmentModel classAttributeAssignmentModel,
                                                               java.util.List<AbstractListItemDTO> dtos)
        Determines whether or not a classification exists in the list of DTOs to avoid creating a duplicate of the exact same entry.
        Parameters:
        classAttributeAssignmentModel - Classification being checked
        dtos - List of existing DTOs to search for a potential match of type
        Returns:
        Whether or not a match is present
      • determineAttributeStatus

        public static ListItemAttributeStatus determineAttributeStatus​(ListItemAttributeDTO dto,
                                                                       ReadService readService)
        Determines the attribute status
        Parameters:
        dto - Attribute DTO to be evaluated
        readService - ReadService instance
        Returns:
        Status of attribute