/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : AssociationInterface.pkg */ /* Version : 8 Jun 2000 */ /* Zone and ModuleZone association functions */ /* */ /***************************************************************************************/ /*************************************************************************************** Return the client or server zone association list from a site Return value: AssociationList (success) or nil (failure) ***************************************************************************************/ fun ASSO_FilterAssociation (site, side)= if side == SCS_SERVER then site.SITEserverAssociations else if side == SCS_CLIENT then site.SITEclientAssociations else { /* ERROR NOT SENT TO END-USER */ logScsError "ASSO_FilterAssociation" "side="::(itoa side)::nil "unknown side value" nil } ;; /*************************************************************************************** Search for associations by zone Return value: [Association r1] (success) or nil (failure) ***************************************************************************************/ fun ASSO_SearchZoneAssociation (site, zone) = let ASSO_FilterAssociation site zone.ZONEsideFlag -> assoList in search_all_in_list assoList @ASSO_AssociationByZone zone ;; /*************************************************************************************** Search for associations by module Return value: [Association r1] (success) or nil (failure) ***************************************************************************************/ fun ASSO_SearchModuleAssociation (site, module) = listcat search_all_in_list site.SITEserverAssociations @ASSO_AssociationByModule module search_all_in_list site.SITEclientAssociations @ASSO_AssociationByModule module ;; /*************************************************************************************** Search for association by module and module zone name Return value: [Association r1] (success) or nil (failure) ***************************************************************************************/ fun ASSO_SearchModuleZoneAssociation (site, module, name, side) = let ASSO_FilterAssociation site side -> assoList in search_in_list assoList @ASSO_AssociationByModuleAndName [module name] ;; fun ASSO_VerifySide (module, moduleZone, side) = let MODULE_GetZonesCS module side -> listZoneModule in isf_in_list listZoneModule @strCompare moduleZone ;; /**************************************************************************************** remove an association between a zone and a module zone Return value: 1 (success) or 0 (failure) ****************************************************************************************/ fun ASSO_RealRemoveAssociation (site, asso) = if asso.ASSOzone.ZONEsideFlag == SCS_CLIENT then set site.SITEclientAssociations = ASSO_RemoveSubAssociation site.SITEclientAssociations asso else set site.SITEserverAssociations = ASSO_RemoveSubAssociation site.SITEserverAssociations asso; SELECT_RemoveAssociation asso::nil REFLEX_PRIORITY_TWO; REFLEX_AssociationRemoved asso::nil nil; 1 ;; /**************************************************************************************** remove an association between a zone and a module zone Return value: 1 (success) or 0 (failure) ****************************************************************************************/ fun ASSO_RemoveAssociatedModule (site, module) = let listcat search_all_in_list site.SITEclientAssociations @ASSO_AssociationByModule module search_all_in_list site.SITEserverAssociations @ASSO_AssociationByModule module -> assoList in REFLEX_AssociationRemoved assoList REFLEX_PRIORITY_TWO; set site.SITEclientAssociations = removef_all_in_list site.SITEclientAssociations @ASSO_AssociationByModule module; set site.SITEserverAssociations = removef_all_in_list site.SITEserverAssociations @ASSO_AssociationByModule module; 1 ;; fun ASSO_RemoveAssociatedZone (site, zone) = let search_all_in_list if zone.ZONEsideFlag == SCS_CLIENT then site.SITEclientAssociations else site.SITEserverAssociations @ASSO_AssociationByZone zone -> assoList in REFLEX_AssociationRemoved assoList REFLEX_PRIORITY_TWO; if zone.ZONEsideFlag == SCS_CLIENT then set site.SITEclientAssociations = removef_all_in_list site.SITEclientAssociations @ASSO_AssociationByZone zone else set site.SITEserverAssociations = removef_all_in_list site.SITEserverAssociations @ASSO_AssociationByZone zone; 1 ;; fun MODULE_RecreateAssociations (site, assoList) = let hd assoList -> asso in if asso.ASSOzone.ZONEsideFlag == SCS_CLIENT then set site.SITEclientAssociations = listcat site.SITEclientAssociations assoList else set site.SITEserverAssociations = listcat site.SITEserverAssociations assoList; REFLEX_AssociationAdded assoList nil; 1 ;; /**************************************************************************************** Add an association between a zone and a module zone Return value: 1 (success) or 0 (failure) ****************************************************************************************/ fun ASSO_FinalAddAssociation (site, asso) = if asso.ASSOzone.ZONEsideFlag == SCS_CLIENT then set site.SITEclientAssociations = ASSO_AddSubAssociation site.SITEclientAssociations asso else set site.SITEserverAssociations = ASSO_AddSubAssociation site.SITEserverAssociations asso; asso ;; fun ASSO_RealAddAssociation (site, zone, module, moduleZone) = if ASSO_VerifySide module moduleZone zone.ZONEsideFlag then let mkAssociation [zone module moduleZone] -> newAsso in ASSO_FinalAddAssociation site newAsso else /* ERROR NOT SENT TO END-USER */ logScsError "ASSO_RealAddAssociation" nil "module zone and zone aren't on same side" nil ;; /*************************************************************************************** Search for all associations for a zone list Return value: [Association r1] (success) or nil (failure) ***************************************************************************************/ fun ASSO_GetAllZoneAssociation (site, zoneList) = let hd zoneList -> zone in let ASSO_FilterAssociation site zone.ZONEsideFlag -> assoList in search_all_in_list assoList @ASSO_AssociationByZoneList zoneList ;; fun ASSO_ProcessAssociationAdded(asso) = { REFLEX_AssociationAdded asso::nil nil; SELECT_NewAssociation asso REFLEX_PRIORITY_TWO; 1 } ;; fun ASSO_RealAddAssociationUndoCompliant (site, asso) = ASSO_ProcessAssociationAdded ASSO_FinalAddAssociation site asso; 1 ;; fun ASSO_RemoveAssociation (site, asso) = { HISTORY_AddCurrentSite _locSCS "asso-REMOVE" (asso.ASSOname)::nil mkfun1 mkfun2 @ASSO_RealAddAssociationUndoCompliant asso site mkfun1 mkfun2 @ASSO_RealRemoveAssociation asso site ; ASSO_RealRemoveAssociation site asso ; } ;; fun ASSO_PrepareUndoAssociationAdded (site, newAsso, oldAsso) = ASSO_RealRemoveAssociation site newAsso; ASSO_RealAddAssociationUndoCompliant site oldAsso ;; proto ASSO_AddAssociation = fun [Site Zone Module S] I;; fun ASSO_AddAssociation (site, zone, module, moduleZone) = { if site == nil then /* ERROR NOT SENT TO END-USER */ logScsError "ASSO_AddAssociation" nil "site is nil" 0 else if zone == nil then /* ERROR NOT SENT TO END-USER */ logScsError "ASSO_AddAssociation" nil "zone is nil" 0 else if module == nil then /* ERROR NOT SENT TO END-USER */ logScsError "ASSO_AddAssociation" nil "module is nil" 0 else if (moduleZone == nil) || (!strcmp moduleZone "") then /* ERROR NOT SENT TO END-USER */ logScsError "ASSO_AddAssociation" nil "module zone is nil or \"\"" 0 else let ASSO_SearchModuleZoneAssociation site module moduleZone zone.ZONEsideFlag -> existingAsso in ( if existingAsso == nil then nil else ASSO_RealRemoveAssociation site existingAsso; let ASSO_RealAddAssociation site zone module moduleZone -> newAsso in ( ASSO_ProcessAssociationAdded newAsso ; HISTORY_AddCurrentSite _locSCS "asso-ADD" newAsso.ASSOname::nil mkfun1 mkfun2 mkfun3 @ASSO_PrepareUndoAssociationAdded existingAsso newAsso site mkfun1 mkfun2 mkfun3 mkfun4 @ASSO_AddAssociation moduleZone module zone site ; 1 ) ) };; fun ASSO_GetZone (asso) = asso.ASSOzone ;; fun ASSO_GetModule (asso) = asso.ASSOmodule ;; fun ASSO_GetName (asso) = asso.ASSOname ;;