Class PredefinedItemUtil

    • Constructor Detail

      • PredefinedItemUtil

        public PredefinedItemUtil()
    • Method Detail

      • getCodeAllowedLength

        public static AllowedLength getCodeAllowedLength​(BasicDbObject obj)
        Gets code allowed length.
        Parameters:
        obj - the object, cannot be null
        Returns:
        the allowed length
      • getCodeLength

        public static int getCodeLength​(BasicDbObject obj)
        Gets code length.
        Parameters:
        obj - the object, cannot be null
        Returns:
        the code length
      • getCodeType

        public static org.eclipse.emf.common.util.Enumerator getCodeType​(BasicDbObject obj)
        Gets code type if supports.
        Parameters:
        obj - the object, cannot be null
        Returns:
        the code type, if not supported returns null
      • getContent

        public static List<? extends PredefinedItem> getContent​(org.eclipse.emf.ecore.EObject item)
        Get predefined item content.
        Parameters:
        item - the predefined item, cannot be null
        Returns:
        the content
      • getItems

        public static List<? extends PredefinedItem> getItems​(org.eclipse.emf.ecore.EObject obj)
        Gets model or Predefined predefined items.
        Parameters:
        obj - the object or predefined, cannot be null
        Returns:
        the items
      • getLevelCount

        public static int getLevelCount​(org.eclipse.emf.ecore.EObject obj)
        Gets level count if supports.
        Parameters:
        obj - the object, cannot be null
        Returns:
        the level count or -1 if not supported
      • getPredefined

        public static Predefined getPredefined​(org.eclipse.emf.ecore.EObject obj)
        Gets model predefined if supports.
        Parameters:
        obj - the object, cannot be null
        Returns:
        the predefined, null if not supported
      • getPredefinedItemCode

        public static Object getPredefinedItemCode​(PredefinedItem item)
        Gets predefined item code.
        Parameters:
        item - the item, cannot be null
        Returns:
        the code, null if not supported
      • getPredefinedItemCodeFeature

        public static org.eclipse.emf.ecore.EStructuralFeature getPredefinedItemCodeFeature​(PredefinedItem item)
        Gets predefined item code.
        Parameters:
        item - the item, cannot be null
        Returns:
        the code, null if not supported
      • getItemsContainer

        public static org.eclipse.emf.ecore.EObject getItemsContainer​(org.eclipse.emf.ecore.EObject predefinedContainer)
        Returns predefined item container.
        Parameters:
        predefinedContainer - the predefined data container, cannot be null
        Returns:
        the predefined item container (predefined or predefined item), otherwise null
      • getItemsFeature

        public static org.eclipse.emf.ecore.EReference getItemsFeature​(org.eclipse.emf.ecore.EObject eObject)
        Returns predefined data items feature if object supports one.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        the feature or null if not supports
      • getPredefinedFeature

        public static org.eclipse.emf.ecore.EReference getPredefinedFeature​(org.eclipse.emf.ecore.EObject eObject)
        Returns predefined data feature if object supports one.
        Parameters:
        eObject - the model, cannot be null
        Returns:
        the feature or null if not supports
      • getPredefinedChildItems

        public static List<? extends PredefinedItem> getPredefinedChildItems​(org.eclipse.emf.ecore.EObject parent)
        Gets model predefined child items if supports.
        Parameters:
        obj - the object, cannot be null
        Returns:
        the child predefined items, empty list if not supported
      • hasOwners

        public static boolean hasOwners​(BasicDbObject obj)
        Returns true if the object has owners.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true if has owners
      • getDescriptionLength

        public static int getDescriptionLength​(BasicDbObject obj)
        Gets description length.
        Parameters:
        obj - the object, cannot be null
        Returns:
        the description length
      • isAutonumbering

        public static boolean isAutonumbering​(BasicDbObject obj)
        Return true if autonumbering used.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true if autonumbering
      • isFixedStringCode

        public static boolean isFixedStringCode​(BasicDbObject obj)
        Checks if object code type is fixed.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true if fixed
      • isHierarchical

        public static boolean isHierarchical​(org.eclipse.emf.ecore.EObject obj)
        Returns true if hierarchical model.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true if is
      • isHierarchyFoldersAndItems

        public static boolean isHierarchyFoldersAndItems​(BasicDbObject obj)
        Returns true if folders and items hierarchy.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true if is
      • isHierarchyOfItems

        public static boolean isHierarchyOfItems​(BasicDbObject obj)
        Returns true if items hierarchy.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true if is
      • isNumberCode

        public static boolean isNumberCode​(BasicDbObject obj)
        Cheks if object has number type code.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true is number type code
      • isNumberCodeType

        public static boolean isNumberCodeType​(org.eclipse.emf.common.util.Enumerator codeType)
        Cheks if code type is number.
        Parameters:
        codeType - the code type, can be null
        Returns:
        true is number
      • isNumberZeroLengthCode

        public static boolean isNumberZeroLengthCode​(BasicDbObject obj)
        Checks if object has zero length code.
        Parameters:
        obj - the object, can be null
        Returns:
        true is zero
      • isPredefinedItemFolder

        public static boolean isPredefinedItemFolder​(Object item)
        Returns true if predefined item is folder.
        Parameters:
        item - the predefined item, cannot be null
        Returns:
        true if is folder
      • isStringCode

        public static boolean isStringCode​(BasicDbObject obj)
        Cheks if object has string type code.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true is string type code
      • isStringCodeType

        public static boolean isStringCodeType​(org.eclipse.emf.common.util.Enumerator codeType)
        Cheks if code type is string.
        Parameters:
        codeType - the code type, can be null
        Returns:
        true is string
      • isWholeObjectCodeSeries

        public static boolean isWholeObjectCodeSeries​(BasicDbObject obj)
        Returns true if model has whole object code series selected.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true is whole object code series
      • isAddEnabledForSelectedPredefinedItem

        public static boolean isAddEnabledForSelectedPredefinedItem​(BasicDbObject basicDbObject,
                                                                    Object selectedObject,
                                                                    boolean isFolder)
        Checks is element adding enabled for selected object for predefined container hierarchy type.
        Parameters:
        basicDbObject - the predefined container, cannot be null
        selectedObject - the selected object, cannot be null
        isFolder - is selected object is predefined item folder.
        Returns:
        true is adding enable
      • isPredefinedSupports

        public static boolean isPredefinedSupports​(Object obj)
        Checks if object supports predefined data.
        Parameters:
        obj - the object-candidate, cannot be null
        Returns:
        true if supports
      • mapStringToValue

        public static Object mapStringToValue​(String stringCodeVaule,
                                              BasicDbObject basicDbObject)
        Maps string code value to metadata model type value by his BasicDbObject code type.
        Parameters:
        stringCodeVaule - the string code value, can be null
        basicDbObject - the BasicDbObject - predefined elements owner, cannot be null
        Returns:
        the metadata model type value for code or String} if codeType is null
      • generatePredefinedItemUniqueCode

        public static String generatePredefinedItemUniqueCode​(BasicDbObject parent)
        Generates unique code for new predefined item in the given parent object.
        Parameters:
        parent - the object in which predefined item will be stored
        Returns:
        generated unique code, never null
      • generatePredefinedItemUniqueName

        public static String generatePredefinedItemUniqueName​(BasicDbObject parent,
                                                              boolean isFolder)
        Generates unique name for new predefined item in the given parent object.
        Parameters:
        parent - the object in which predefined item will be stored
        isFolder - flag indicating that new predefined item will be a folder
        Returns:
        generated unique name, never null
      • isCheckUnique

        public static boolean isCheckUnique​(BasicDbObject obj)
        Return true if check unique used.
        Parameters:
        obj - the object, cannot be null
        Returns:
        true if object checks code uniqueness, false otherwise
      • getCodeAllowedLengthFeature

        public static org.eclipse.emf.ecore.EAttribute getCodeAllowedLengthFeature​(org.eclipse.emf.ecore.EObject eObject)
        Returns e-object code allowed length feature if present.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        the feature or null if not present
      • getCodeLengthFeature

        public static org.eclipse.emf.ecore.EAttribute getCodeLengthFeature​(org.eclipse.emf.ecore.EObject eObject)
        Returns e-object code length feature if present.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        the feature or null if not present
      • getCodeTypeFeature

        public static org.eclipse.emf.ecore.EAttribute getCodeTypeFeature​(org.eclipse.emf.ecore.EObject eObject)
        Returns e-object code type feature if present.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        the feature or null if not present
      • getDescriptionLengthFeature

        public static org.eclipse.emf.ecore.EAttribute getDescriptionLengthFeature​(org.eclipse.emf.ecore.EObject eObject)
        Returns e-object description length feature if present.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        the feature or null if not present
      • canCodeEdit

        public static boolean canCodeEdit​(org.eclipse.emf.ecore.EObject eObject)
        Checks code edit ability.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        true if can, false otherwise
      • canDescriptionEdit

        public static boolean canDescriptionEdit​(org.eclipse.emf.ecore.EObject eObject)
        Checks description edit ability.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        true if can, false otherwise
      • canTypeDescriptionEdit

        public static boolean canTypeDescriptionEdit​(org.eclipse.emf.ecore.EObject eObject)
        Checks type description edit ability.
        Parameters:
        eObject - the e-object, cannot be null
        Returns:
        true if can, false otherwise
      • normalizeCode

        public static String normalizeCode​(boolean fixedStringCodeType,
                                           boolean numberCodeType,
                                           int codeLength,
                                           String code)
        Normalizes code for fixed string code or empty number code or null code.
        Parameters:
        fixedStringCodeType - the fixed string code type
        numberCodeType - the fixed string code type
        codeLength - the code length
        code - the initial code, can be null
        Returns:
        normalized code, cannot be null