Jump to content
Changes to the Jaspersoft community edition download ×
  • Visualize.js - API Notes and Samples - ResourcesSearch


    nesterone
    • Features: JasperReports Server Version: v5.6 Product: Visualize.js

    [toc on_off::hide=0 box::collapsed=1]

    API Reference

    Schema

    Resources Search Properties Schema

    {
        "type": "object",
        "properties": {
            "server": {
                "type": "string",
                "description": "Url to JRS instance."
            },
            "q": {
                "type": "string",
                "description": "Query string. Search for occurrence in label or description of resource."
            },
            "folderUri": {
                "type": "string",
                "description": "Parent folder URI.",
                "pattern": "^/\\w*(/\\w+)*$"
            },
            "type": {
                "type": "string",
                "description": "Type of resources to search.",
                "enum": [
                    "folder",
                    "dataType",
                    "jdbcDataSource",
                    "awsDataSource",
                    "jndiJdbcDataSource",
                    "virtualDataSource",
                    "customDataSource",
                    "beanDataSource",
                    "xmlaConnection",
                    "listOfValues",
                    "file",
                    "reportOptions",
                    "dashboard",
                    "adhocDataView",
                    "query",
                    "olapUnit",
                    "reportUnit",
                    "domainTopic",
                    "semanticLayerDataSource",
                    "secureMondrianConnection",
                    "mondrianXmlaDefinition",
                    "mondrianConnection",
                    "inputControl"
                ]
            },
            "offset": {
                "type": "integer",
                "description": "Pagination. Index of first resource to show.",
                "minimum": 0
            },
            "limit": {
                "type": "integer",
                "description": "Pagination. Resources count per page.",
                "minimum": 0
            },
            "recursive": {
                "type": "boolean",
                "description": "Flag indicates if search should be recursive."
            },
            "sortBy": {
                "type": "string",
                "description": "Field to sort on.",
                "enum": [
                    "uri",
                    "label",
                    "description",
                    "type",
                    "creationDate",
                    "updateDate",
                    "accessTime",
                    "popularity"
                ]
            },
            "accessType": {
                "type": "string",
                "description": "Filtering by type of access, e.g. what was done with resource.",
                "enum": [
                    "viewed",
                    "modified"
                ]
            },
            "showHiddenItems": {
                "type": "boolean",
                "description": "Flag indicates if hidden items should present in results."
            },
            "forceTotalCount": {
                "type": "boolean",
                "description": "If true, Total-Count header is always set (impact on performance), otherwise - in first page only"
            }
        },
        "required": ["server"]
    }
    

    ResourcesSearch Module

    /**
    * Constructor. Takes context as argument.
    * @param contextObj - map of properties.   
    */
    function ResourcesSearch(contextObj){};
    /**
    * Get/Set 'q' parameter of the query
    * @param contextObj - map of properties.
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.q= function(value){};
    /**
    * Get/Set 'folderUri' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.folderUri= function(value){};
    /**
    * Get/Set 'type' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.type= function(value){};
    /**
    * Get/Set 'offset' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.offset= function(value){};
    /**
    * Get/Set 'limit' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.limit= function(value){};
    /**
    * Get/Set 'recursive' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.recursive= function(value){};
    /**
    * Get/Set 'sortBy' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.sortBy= function(value){};
    /**
    * Get/Set 'accessType' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.accessType= function(value){};
    /**
    * Get/Set 'showHiddenItems' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.showHiddenItems= function(value){};
    /**
    * Get/Set 'forceTotalCount' parameter of the query
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    ResourcesSearch.prototype.forceTotalCount= function(value){};
    

    Workflows

    Make simple call to server

    new ResourcesSearch({
        server:"",
        folderUri: "/public",
        recursive: false
    })).run(function(resourceLookups){
        // results here
    })
    

    Make simple call to server with error handler (2nd parameter of 'run')

    new ResourcesSearch({
        server:"",
        folderUri: "/public",
        recursive: false
    })).run(usefulFunction, function(error){
        alert(error);
    }))
    

    Make simple call to server with 'always' (run every time when operation ends) handler (3rd parameter of 'run')

    new ResourcesSearch({
        server:"",
        folderUri: "/public",
        recursive: false
    })).run(usefulFunction, errorHandler, function(resultOrError){
        alert(resultOrError);
    }))
    

    Reuse instance to make close calls

    var folderContentQuery = new ResourcesSearch({
        server:"",
        recursive: false
    }));
    
    ......
    // call 1
    folderContentQuery.folderUri("/uri1").run(doSomethingWithResultFunction);
    
    ......
    // call 2 after some time
    folderContentQuery.folderUri("/uri2").run(doSomethingWithResultFunction);
    

    Reuse results later

    var call = new ResourcesSearch({
        server:"",
        folderUri: "/public",
        recursive: false
    })).run(function(resourceLookups){
        // results here, data() available, i.e it this point call.data() === resourceLookups -> true
    });
    // at this point call.data() will return null until the run callback will be called. 
    call.data() === null // -> true
    
    .....
    // if some data was obtained earlier, it accessible via data()
    var resourceLookups = call.data();
    

    Validate set properties without actual call

    var call = new ResourcesSearch({
        server:"",
        folderUri: "/public",
        recursive: false
    }));
    
    var error = call.validate();
    
    if (!error){
        // valid
    } else {
        // invalid, read details from error
    }
    

    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...