package gw.exportimport uses gw.lang.reflect.TypeSystem uses java.lang.IllegalArgumentException @ReadOnly enhancement EntityFlowMaskDataEnhancement : entity.EntityFlowMaskData { property get EntityType() : Type { return this.EntityTypeName?.NotBlank ? TypeSystem.getByFullName(this.EntityTypeName) : null } property set EntityType(type : Type) { var newTypeName = type?.Name this.EntityTypeName = newTypeName if ( this.EntityTypeName != newTypeName ) { // new type clears encoding since identifiers are different... this.MaskIdentifiersEncoding = null } } property get MaskIdentifiers() : String[] { return this.MaskIdentifiersEncoding == null ? {} : this.MaskIdentifiersEncoding?.split(",") } property set MaskIdentifiers(ids : String[]) { this.MaskIdentifiersEncoding = encodeIdentifiers(ids) } /** * Encode an array of identifiers. */ static function encodeIdentifiers(ids : String[]) : String { return ( ( ids == null ) or ids.IsEmpty ) ? null : ids.join(",") } /** * Set the specified mask as the default for its entity type unsetting the * current default, if any. * * The current default mask must be input to be able to set the input mask * as the default since the current must be unset as the default. Failure * to do so will cause consistency failures. This also will not set the * specified mask as default if the specified current mask is not the default. */ static function setAsDefaultMask(mask : EntityFlowMaskData, currentDefaultMask : EntityFlowMaskData) { if ( mask == null ) { throw new IllegalArgumentException("EntityFlowMaskData.setAsDefaultMask: Mask cannot be null!") } /* get default entry... */ var entityTypeDefault : EntityFlowMaskDefault if ( currentDefaultMask == null ) { // create new default entry... entityTypeDefault = new EntityFlowMaskDefault(mask.Bundle) entityTypeDefault.EntityTypeName = mask.EntityType.Name } else { if ( mask.EntityType != currentDefaultMask.EntityType ) { throw new IllegalArgumentException( "EntityFlowMaskData.setAsDefaultMask: Mask must be for the same entity type.") } // add to bundle for reassignment... currentDefaultMask = mask.Bundle.add(currentDefaultMask) entityTypeDefault = currentDefaultMask.Default // unassign so default entry can be reassigned... currentDefaultMask.Default = null } if ( entityTypeDefault.DefaultMask != mask ) { // assign default entry to new default... mask.Default = entityTypeDefault } } }