Changeset 4125


Ignore:
Timestamp:
12/02/13 14:13:59 (11 years ago)
Author:
George.Georgovassilis@mpi.nl
Message:

#465: new service for querying components in groups

Location:
ComponentRegistry/branches/ComponentRegistry-1.14.0
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/BrowserOverviewList.mxml

    r4093 r4125  
    156156                                        event.preventDefault();
    157157                                } else{
     158                                        if (dataGrid.selectedItem == null)
     159                                                return;
    158160                                        var groupId:String = event.getGroupId();
    159161                                        Alert.show("Items, once moved to a group, can not be moved back to your workspace. Do you want to move this item?", "Title", mx.controls.Alert.YES | mx.controls.Alert.NO, this, function (nestedCloseEvent:CloseEvent):void {
     
    171173                                currentSelectedGroup=groupBox.selectedItem.groupId;
    172174                                var groupEvent:GroupSelectionEvent = new GroupSelectionEvent(groupBox.selectedItem.groupId, groupBox.selectedItem.label);
    173                                 dispatchEvent(groupEvent);
     175                                Config.instance.dispatchEvent(groupEvent);
    174176                                // did someone object this selection?
    175177                                if (groupEvent.isDefaultPrevented()){
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/components/ExpandingComponentLabel.as

    r3660 r4125  
    1313        import flash.display.DisplayObject;
    1414        import flash.events.MouseEvent;
    15 
     15       
    1616        import mx.containers.VBox;
     17        import mx.controls.Alert;
    1718        import mx.controls.Label;
    1819        import mx.managers.CursorManager;
     
    3031
    3132                private var editable:Boolean;
     33               
     34                protected function setItem(item:ItemDescription):void{
     35                        this.item = item;
     36                }
    3237
    3338                public function ExpandingComponentLabel(componentId:String, editable:Boolean = false) {
     
    4348                                this.setStyle("borderColor", StyleConstants.USER_BORDER_COLOR);
    4449                        }
     50                        //unfortunately the componend and profile services may overlook components from groups, so we have to ask the backend
     51                        if (item!=null)
     52                                updateView();
     53                        else{
     54                                Config.instance.getComponentsSrv(Config.SPACE_USER).getComponent(componentId, function(item:ItemDescription):void{
     55                                        setItem(item);
     56                                        updateView();
     57                                });
     58                        }
    4559                }
    46 
    47                 protected override function createChildren():void {
    48                         super.createChildren();
     60               
     61                private function updateView():void{
    4962                        var id:Label = new Label();
    5063                        if (item) {
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/BaseRemoteService.as

    r3368 r4125  
    4343                 */
    4444                protected function dispatchRequest(url:URI):void {
    45                         trace(url);
    4645                        readService.setUrl(url);
    4746                        var token:AsyncToken = readService.send();
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/BrowserService.as

    r3660 r4125  
    4343                        for each (var item:ItemDescription in itemDescriptions) {
    4444                                if (item.id == id) {
    45                                         trace("found "+ id+" in "+itemDescriptions.length+" userSpace= "+space);
    4645                                        return item;
    4746                                }
    4847                        }
    49                         trace("not found "+ id+" in "+itemDescriptions+" userSpace= "+space);
    5048                        return null;
    5149                }
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/ComponentRegistryService.as

    r3660 r4125  
    11package clarin.cmdi.componentregistry.services //trunk
    22{
     3        import clarin.cmdi.componentregistry.common.ItemDescription;
    34        import clarin.cmdi.componentregistry.services.remote.RemoteService;
    45       
    56        import com.adobe.net.URI;
    67       
     8        import mx.controls.Alert;
     9        import mx.rpc.AsyncToken;
     10        import mx.rpc.Responder;
    711        import mx.rpc.http.HTTPService;
    812       
     
    3034                }
    3135               
     36                public function getComponent(componentId:String, callback:Function):void{
     37                        readService.setUrl(new URI(Config.instance.serviceRootUrl+Config.ITEMS_URL+"/"+componentId+"?userspace=true"));
     38                        var token:AsyncToken = readService.send();
     39                        token.addResponder(new Responder(function(resultEvent):void{
     40                                var resultXml:XML = resultEvent.result as XML;
     41                                var item:ItemDescription = new ItemDescription();
     42                                item.createComponent(resultXml, "user");
     43                                callback(item);
     44                        }, this.requestCallbackFailed));
     45                }
     46               
    3247        }
    3348}
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/Config.as

    r4093 r4125  
    4545                public static const SPACE_PUBLIC:String = "public";
    4646               
    47                 private static const COMPONENT_LIST_URL:String = "/rest/registry/components";
     47                public static const COMPONENT_LIST_URL:String = "/rest/registry/components";
     48                public static const ITEMS_URL:String= "/rest/registry/items";
    4849                private static const PROFILE_LIST_URL:String = "/rest/registry/profiles";
    4950                private static const COMPONENT_USAGE_URL:String = "/rest/registry/components/usage/";
     
    190191
    191192                public function getGroupsOfItemPath(itemId:String):String{
    192                         return _serviceRootUrl + "/rest/registry/items/"+itemId+"/groups";
     193                        return _serviceRootUrl + ITEMS_URL+"/"+itemId+"/groups";
    193194                }
    194195
     
    231232               
    232233                public function getTransferItemOwnershipUrl(itemId:String,groupId:String):String{
    233                         return _serviceRootUrl + "/rest/registry/items/"+itemId+"/transferownership?groupId="+groupId;
     234                        return _serviceRootUrl + ITEMS_URL+"/"+itemId+"/transferownership?groupId="+groupId;
    234235                }
    235236
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r3660 r4125  
    15821582        }
    15831583
     1584        @Override
     1585        @GET
     1586        @Path("/items/{itemId}")
     1587        @Produces({ MediaType.TEXT_XML, MediaType.APPLICATION_XML,
     1588                        MediaType.APPLICATION_JSON })
     1589        public ComponentDescription getComponentDescription(@PathParam("itemId") String itemId) throws ComponentRegistryException{
     1590                        LOG.debug("Item with id: {} is requested.", itemId);
     1591                        ComponentDescription description = getRegistry(getStatus(false)).getComponentDescription(itemId);
     1592                        if (description == null)
     1593                                description = getRegistry(getStatus(true)).getComponentDescription(itemId);
     1594                        return description;
     1595        }
     1596
    15841597}
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/IComponentRegistryRestService.java

    r3660 r4125  
    238238         */
    239239        void transferItemOwnershipToGroup(String itemId, long groupId);
     240       
     241        /**
     242         * Get any component (public or private) with the specified ID
     243         * @param componentId
     244         * @return
     245         */
     246        ComponentDescription getComponentDescription(String componentId) throws ComponentRegistryException;
    240247
    241248}
  • ComponentRegistry/branches/ComponentRegistry-1.14.0/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTest.java

    r3449 r4125  
    12301230        assertEquals(root.getCMDComponent().get(1).getCMDComponent().get(2).getFilename(), null);
    12311231    }
     1232   
     1233    @Test
     1234    public void testGetDescription() throws Exception{
     1235        fillUp();
     1236        ComponentDescription component = getResource().path("/registry/items/clarin.eu:cr1:component1").accept(MediaType.APPLICATION_JSON).get(ComponentDescription.class);
     1237        assertNotNull(component);
     1238        assertEquals("clarin.eu:cr1:component1", component.getId());
     1239        assertEquals("component1", component.getName());
     1240        assertEquals("Test Description", component.getDescription());
     1241
     1242    }
    12321243}
Note: See TracChangeset for help on using the changeset viewer.