Changeset 1475
- Timestamp:
- 07/27/11 13:55:35 (13 years ago)
- Location:
- ComponentRegistry/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/EditorAS.as
r1473 r1475 105 105 // Private components that are in updated require usage check call. If in use, the user can choose whether or not to save the changes . 106 106 if(inUserSpace && uploadAction == UploadService.UPDATE && !item.isProfile){ 107 checkUsage(item );107 checkUsage(item, inUserSpace); 108 108 }else{ 109 109 doUpload(uploadAction,item); … … 117 117 * Calls usage check for the specified component. If in use, asks user whether to proceed; if positive, initiates update. 118 118 */ 119 private function checkUsage(item:ItemDescription, uploadAction:int = UploadService.UPDATE):void{120 var componentUsageService:ComponentUsageService = new ComponentUsageService(item );119 private function checkUsage(item:ItemDescription, inUserSpace:Boolean = true, uploadAction:int = UploadService.UPDATE):void{ 120 var componentUsageService:ComponentUsageService = new ComponentUsageService(item,inUserSpace); 121 121 componentUsageService.addEventListener(ComponentUsageCheckEvent.COMPONENT_IN_USE, 122 122 function (event:ComponentUsageCheckEvent):void{ 123 123 if(event.isComponentInUse){ 124 Alert.show("Component is used by other components and/or profiles. Changes in this component will affect these. Do you want to proceed?","Component is used", Alert.YES|Alert.NO,null, 124 var messageBody:String = "The component you are about to save is used by the following component(s) and/or profile(s):\n\n"; 125 for each(var name:String in event.itemUsingComponent){ 126 messageBody += " - " + name + "\n"; 127 } 128 messageBody += "\nChanges in this component will affect the above. Do you want to proceed?"; 129 Alert.show(messageBody,"Component is used", Alert.YES|Alert.NO,null, 125 130 function (eventObj:CloseEvent):void{ 126 131 if(eventObj.detail == Alert.YES){ -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/ComponentUsageCheckEvent.as
r1473 r1475 3 3 import flash.events.Event; 4 4 5 import mx.collections.ArrayCollection; 6 5 7 public class ComponentUsageCheckEvent extends Event 6 8 { 7 9 public static const COMPONENT_IN_USE:String = "componentInUse"; 10 private var _itemsUsingComponent:ArrayCollection; 8 11 9 public function ComponentUsageCheckEvent(type:String, componentInUse:Boolean,bubbles:Boolean = false, cancelable:Boolean = false)12 public function ComponentUsageCheckEvent(type:String, itemsUsingComponent:ArrayCollection, bubbles:Boolean = false, cancelable:Boolean = false) 10 13 { 11 14 super(type, bubbles, cancelable); 12 this._isComponentInUse = componentInUse;15 _itemsUsingComponent = itemsUsingComponent; 13 16 } 14 17 … … 16 19 17 20 public function get isComponentInUse():Boolean{ 18 return _isComponentInUse; 21 return _itemsUsingComponent != null && _itemsUsingComponent.length > 0; 22 } 23 24 /** 25 * Names of components that use the specified item 26 */ 27 public function get itemUsingComponent():ArrayCollection{ 28 return _itemsUsingComponent; 19 29 } 20 30 } -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/ComponentUsageService.as
r1473 r1475 8 8 import flash.events.EventDispatcher; 9 9 10 import mx.collections.ArrayCollection; 10 11 import mx.controls.Alert; 11 12 import mx.messaging.messages.HTTPRequestMessage; … … 15 16 import mx.rpc.events.ResultEvent; 16 17 import mx.rpc.http.HTTPService; 17 18 18 import mx.utils.StringUtil; 19 19 20 /** 21 * Service that calls registry/components/usage/{id} for the specified component, which is used to check 22 * whether the component is used by any other components or profiles in the same registry. 23 */ 20 24 [Event(name="componentInUse", type="clarin.cmdi.componentregistry.services.ComponentUsageCheckEvent")] 21 25 public class ComponentUsageService extends EventDispatcher 22 26 { 23 27 private var service:HTTPService; 24 private var serviceUrl:String;25 28 26 public function ComponentUsageService(itemDescription:ItemDescription )29 public function ComponentUsageService(itemDescription:ItemDescription, userSpace:Boolean) 27 30 { 28 31 var url:URI = new URI(Config.instance.componentUsageUrl + itemDescription.id); 32 if (userSpace) { 33 url.setQueryValue(Config.PARAM_USERSPACE, "true"); 34 } 29 35 30 36 service = new HTTPService(); … … 41 47 42 48 private function result(resultEvent:ResultEvent):void { 49 // Result contains list of items that use the specified component 43 50 var resultXml:XML = resultEvent.result as XML; 44 dispatchEvent(new ComponentUsageCheckEvent(ComponentUsageCheckEvent.COMPONENT_IN_USE, true)); 51 52 // Collect item names so the view can show them to the user 53 var resultItems:ArrayCollection = new ArrayCollection(); 54 for each (var description:XML in resultXml.children()) { 55 resultItems.addItem(description.name.toString()); 56 } 57 58 var event:ComponentUsageCheckEvent = new ComponentUsageCheckEvent(ComponentUsageCheckEvent.COMPONENT_IN_USE, resultItems); 59 dispatchEvent(event); 45 60 } 46 61 -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r1463 r1475 205 205 @Path("/components/usage/{componentId}") 206 206 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 207 public List<AbstractDescription> getComponentUsage(@PathParam("componentId") String componentId, @QueryParam(USERSPACE_PARAM) @DefaultValue(" false") boolean userspace) throws ComponentRegistryException {207 public List<AbstractDescription> getComponentUsage(@PathParam("componentId") String componentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("true") boolean userspace) throws ComponentRegistryException { 208 208 try { 209 209 final long start = System.currentTimeMillis();
Note: See TracChangeset
for help on using the changeset viewer.