Android Open Source - js-android-sdk Resource Descriptor






From Project

Back to project page js-android-sdk.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project js-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved.
 * http://www.jaspersoft.com./*  w w  w. j a v a2s  .c om*/
 *
 * Unless you have purchased a commercial license agreement from Jaspersoft,
 * the following license terms apply:
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of  the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public  License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package com.jaspersoft.android.sdk.client.oxm;

import android.util.Log;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

import java.util.ArrayList;
import java.util.List;

/**
 * This class represents a resource descriptor entity for convenient XML serialization process.
 *
 * @author Ivan Gadzhega
 * @version $Id$
 * @since 1.0
 */

@Root(strict=false)
public class ResourceDescriptor {

    /**
     * These constants are copied here from DataType for facility
     */
    public static final byte DT_TYPE_TEXT = 1;
    public static final byte DT_TYPE_NUMBER = 2;
    public static final byte DT_TYPE_DATE = 3;
    public static final byte DT_TYPE_DATE_TIME = 4;

    /**
     * These constants are copied here from InputControl for facility
     */
    public static final byte IC_TYPE_BOOLEAN = 1;
    public static final byte IC_TYPE_SINGLE_VALUE = 2;
    public static final byte IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES = 3;
    public static final byte IC_TYPE_SINGLE_SELECT_QUERY = 4;
    public static final byte IC_TYPE_MULTI_VALUE = 5;
    public static final byte IC_TYPE_MULTI_SELECT_LIST_OF_VALUES = 6;
    public static final byte IC_TYPE_MULTI_SELECT_QUERY = 7;

    public static final byte IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES_RADIO = 8;
    public static final byte IC_TYPE_SINGLE_SELECT_QUERY_RADIO = 9;
    public static final byte IC_TYPE_MULTI_SELECT_LIST_OF_VALUES_CHECKBOX = 10;
    public static final byte IC_TYPE_MULTI_SELECT_QUERY_CHECKBOX = 11;

    public static final String PROP_VERSION = "PROP_VERSION";
    public static final String PROP_PARENT_FOLDER = "PROP_PARENT_FOLDER";
    public static final String PROP_RESOURCE_TYPE = "PROP_RESOURCE_TYPE";
    public static final String PROP_CREATION_DATE = "PROP_CREATION_DATE";

    // File resource properties
    public static final String PROP_FILERESOURCE_HAS_DATA = "PROP_HAS_DATA";
    public static final String PROP_FILERESOURCE_IS_REFERENCE = "PROP_IS_REFERENCE";
    public static final String PROP_FILERESOURCE_REFERENCE_URI = "PROP_REFERENCE_URI";
    public static final String PROP_FILERESOURCE_WSTYPE = "PROP_WSTYPE";
    public static final String PROP_DATA = "PROP_DATA";
    public static final String PROP_DATASOURCE_MAPPING = "DATASOURCE_MAPPING";

    // Datasource properties
    public static final String PROP_DATASOURCE_DRIVER_CLASS = "PROP_DATASOURCE_DRIVER_CLASS";
    public static final String PROP_DATASOURCE_CONNECTION_URL = "PROP_DATASOURCE_CONNECTION_URL";
    public static final String PROP_DATASOURCE_USERNAME = "PROP_DATASOURCE_USERNAME";
    public static final String PROP_DATASOURCE_PASSWORD = "PROP_DATASOURCE_PASSWORD";
    public static final String PROP_DATASOURCE_JNDI_NAME = "PROP_DATASOURCE_JNDI_NAME";
    public static final String PROP_DATASOURCE_BEAN_NAME = "PROP_DATASOURCE_BEAN_NAME";
    public static final String PROP_DATASOURCE_BEAN_METHOD = "PROP_DATASOURCE_BEAN_METHOD";
    //
    public static final String PROP_DATASOURCE_CUSTOM_SERVICE_CLASS = "PROP_DATASOURCE_CUSTOM_SERVICE_CLASS";
    public static final String PROP_DATASOURCE_CUSTOM_PROPERTY_MAP = "PROP_DATASOURCE_CUSTOM_PROPERTY_MAP";


    // ReportUnit resource properties
    public static final String PROP_RU_DATASOURCE_TYPE = "PROP_RU_DATASOURCE_TYPE";
    public static final String PROP_RU_IS_MAIN_REPORT = "PROP_RU_IS_MAIN_REPORT";
    public static final String PROP_RU_INPUTCONTROL_RENDERING_VIEW = "PROP_RU_INPUTCONTROL_RENDERING_VIEW";
    public static final String PROP_RU_REPORT_RENDERING_VIEW = "PROP_RU_REPORT_RENDERING_VIEW";
    public static final String PROP_RU_ALWAYS_PROPMT_CONTROLS = "PROP_RU_ALWAYS_PROPMT_CONTROLS";
    public static final String PROP_RU_CONTROLS_LAYOUT = "PROP_RU_CONTROLS_LAYOUT";

    public static final byte RU_CONTROLS_LAYOUT_POPUP_SCREEN = 1;
    public static final byte RU_CONTROLS_LAYOUT_SEPARATE_PAGE = 2;
    public static final byte RU_CONTROLS_LAYOUT_TOP_OF_PAGE = 3;
    public static final byte RU_CONTROLS_LAYOUT_IN_PAGE = 4;

    // DataType resource properties
    public static final String PROP_DATATYPE_STRICT_MAX = "PROP_DATATYPE_STRICT_MAX";
    public static final String PROP_DATATYPE_STRICT_MIN = "PROP_DATATYPE_STRICT_MIN";
    public static final String PROP_DATATYPE_MIN_VALUE = "PROP_DATATYPE_MIN_VALUE";
    public static final String PROP_DATATYPE_MAX_VALUE = "PROP_DATATYPE_MAX_VALUE";
    public static final String PROP_DATATYPE_PATTERN = "PROP_DATATYPE_PATTERN";
    public static final String PROP_DATATYPE_TYPE = "PROP_DATATYPE_TYPE";

    // ListOfValues resource properties
    public static final String PROP_LOV = "PROP_LOV";
    public static final String PROP_LOV_LABEL = "PROP_LOV_LABEL";
    public static final String PROP_LOV_VALUE = "PROP_LOV_VALUE";


    // InputControl resource properties
    public static final String PROP_INPUTCONTROL_TYPE = "PROP_INPUTCONTROL_TYPE";
    public static final String PROP_INPUTCONTROL_IS_MANDATORY = "PROP_INPUTCONTROL_IS_MANDATORY";
    public static final String PROP_INPUTCONTROL_IS_READONLY = "PROP_INPUTCONTROL_IS_READONLY";
    public static final String PROP_INPUTCONTROL_IS_VISIBLE = "PROP_INPUTCONTROL_IS_VISIBLE";

    // SQL resource properties
    public static final String PROP_QUERY = "PROP_QUERY";
    public static final String PROP_QUERY_VISIBLE_COLUMNS = "PROP_QUERY_VISIBLE_COLUMNS";
    public static final String PROP_QUERY_VISIBLE_COLUMN_NAME = "PROP_QUERY_VISIBLE_COLUMN_NAME";
    public static final String PROP_QUERY_VALUE_COLUMN = "PROP_QUERY_VALUE_COLUMN";
    public static final String PROP_QUERY_LANGUAGE = "PROP_QUERY_LANGUAGE";


    // SQL resource properties
    public static final String PROP_QUERY_DATA = "PROP_QUERY_DATA";
    public static final String PROP_QUERY_DATA_ROW = "PROP_QUERY_DATA_ROW";
    public static final String PROP_QUERY_DATA_ROW_COLUMN = "PROP_QUERY_DATA_ROW_COLUMN";


    // OLAP XMLA Connection
    public static final String PROP_XMLA_URI = "PROP_XMLA_URI";
    public static final String PROP_XMLA_CATALOG = "PROP_XMLA_CATALOG";
    public static final String PROP_XMLA_DATASOURCE = "PROP_XMLA_DATASOURCE";
    public static final String PROP_XMLA_USERNAME = "PROP_XMLA_USERNAME";
    public static final String PROP_XMLA_PASSWORD = "PROP_XMLA_PASSWORD";

    // OLAP Unit
    public static final String PROP_MDX_QUERY = "PROP_MDX_QUERY";

    public enum WsType {
        accessGrantSchema,
        adhocDataView,
        adhocReport,
        aws,
        bean,
        contentResource,
        css,
        custom,
        datasource,
        dataType,
        dashboard,
        dashboardState,
        domain,
        domainTopic,
        folder,
        font,
        img,
        inputControl,
        jar,
        jdbc,
        jndi,
        jrxml,
        lov,
        olapMondrianCon,
        olapMondrianSchema,
        olapUnit,
        olapXmlaCon,
        prop,
        query,
        reference,
        reportOptions,
        reportUnit,
        virtual,
        xml,
        xmlaConnection,
        unknow
    }

    // Convenient TAG for logging purposes
    private static final String TAG = "ResourceDescriptor";

    @Attribute(required=false)
    private String name;
    @Attribute
    private String wsType;
    @Attribute(required=false)
    private String uriString;
    @Attribute(required=false)
    private Boolean isNew;

    @Element(required=false)
    private String label;
    @Element(required=false)
    private String description;
    @Element(required=false)
    private String creationDate;

    @ElementList(entry="resourceProperty", inline=true, required=false, empty=false)
    private List<ResourceProperty> properties;

    @ElementList(entry="resourceDescriptor", inline=true, required=false, empty=false)
    private List<ResourceDescriptor> internalResources;

    @ElementList(entry="parameter", inline=true, required=false, empty=false)
    private List<ResourceParameter> parameters;


    /**
     * Looks the wsType of the resource descriptor and return true
     * if it is one of the following: datasource, jdbc, jndi, bean, custom.
     * @return <code>true</code> if it is data source, <code>false</code> otherwise.
     */
    public boolean isDataSource() {
        switch (getWsType()) {
            case datasource:
            case jdbc:
            case jndi:
            case bean:
            case custom:
                return true;
            default:
                return false;
        }
    }

    /**
     * Gets a valid data source resource from a resource descriptor
     * @return the data source resource, or <code>null</code> if no data source is found.
     */
    public ResourceDescriptor getDataSource() {
        for (ResourceDescriptor internalResource : getInternalResources()) {
            if (internalResource.isDataSource()) {
                return internalResource;
            }
        }
        return null;
    }

    /**
     * Gets a valid data source uri from a resource descriptor
     * @return the data source uri, or <code>null</code> if no data source is found.
     */
    public String getDataSourceUri() {
        for (ResourceDescriptor internalResource : getInternalResources()) {
            switch (internalResource.getWsType()) {
                case datasource:
                    return internalResource.getPropertyByName(PROP_FILERESOURCE_REFERENCE_URI).getValue();
                case jdbc:
                case jndi:
                case bean:
                case custom:
                    return internalResource.getUriString();
            }
        }
        // TODO: data source references
        return null;
    }

    /**
     * Gets the property with the specified name
     * @param name the property name
     * @return property with the specified name, or <code>null</code> if the property is not found
     */
    public ResourceProperty getPropertyByName(String name) {
        for (ResourceProperty property : getProperties()) {
            if (name.equals(property.getName())) {
                return property;
            }
        }
        return null;
    }

    /**
     * Gets the list of internal resources with the specified type
     * @param type the resource type
     * @return the list of resources that have the specified type
     */
    public List<ResourceDescriptor> getInternalResourcesByType(WsType type) {
        List<ResourceDescriptor> resourcesByType = new ArrayList<ResourceDescriptor>();
        for(ResourceDescriptor resource : this.getInternalResources()) {
            if(this.getWsType() == type) {
                resourcesByType.add(resource);
            }
        }
        return resourcesByType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public WsType getWsType() {
        try {
            return WsType.valueOf(wsType);
        } catch (IllegalArgumentException ex) {
            Log.w(TAG, wsType + " is not a constant in WsType enum");
            return WsType.unknow;
        }
    }

    public void setWsType(WsType wsType) {
        this.wsType = wsType.toString();
    }

    public String getUriString() {
        return uriString;
    }

    public void setUriString(String uriString) {
        this.uriString = uriString;
    }

    public Boolean getNew() {
        return isNew;
    }

    public void setNew(Boolean aNew) {
        isNew = aNew;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(String creationDate) {
        this.creationDate = creationDate;
    }

    public List<ResourceProperty> getProperties() {
        return properties;
    }

    public void setProperties(List<ResourceProperty> properties) {
        this.properties = properties;
    }

    public List<ResourceDescriptor> getInternalResources() {
        return internalResources;
    }

    public void setInternalResources(List<ResourceDescriptor> internalResources) {
        this.internalResources = internalResources;
    }

    public List<ResourceParameter> getParameters() {
        return parameters;
    }

    public void setParameters(List<ResourceParameter> parameters) {
        this.parameters = parameters;
    }
}




Java Source Code List

com.jaspersoft.android.sdk.client.JsRestClient.java
com.jaspersoft.android.sdk.client.JsServerProfile.java
com.jaspersoft.android.sdk.client.async.JsAsyncTaskManager.java
com.jaspersoft.android.sdk.client.async.JsOnTaskCallbackListener.java
com.jaspersoft.android.sdk.client.async.JsProgressTracker.java
com.jaspersoft.android.sdk.client.async.JsXmlSpiceService.java
com.jaspersoft.android.sdk.client.async.request.BaseRequest.java
com.jaspersoft.android.sdk.client.async.request.CheckReportStatusRequest.java
com.jaspersoft.android.sdk.client.async.request.DeleteResourceRequest.java
com.jaspersoft.android.sdk.client.async.request.GetRootFolderDataRequest.java
com.jaspersoft.android.sdk.client.async.request.ModifyResourceRequest.java
com.jaspersoft.android.sdk.client.async.request.ReportDetailsRequest.java
com.jaspersoft.android.sdk.client.async.request.RunReportExecutionRequest.java
com.jaspersoft.android.sdk.client.async.request.RunReportExportOutputRequest.java
com.jaspersoft.android.sdk.client.async.request.RunReportExportsRequest.java
com.jaspersoft.android.sdk.client.async.request.SaveExportAttachmentRequest.java
com.jaspersoft.android.sdk.client.async.request.SaveExportOutputRequest.java
com.jaspersoft.android.sdk.client.async.request.SaveReportAttachmentRequest.java
com.jaspersoft.android.sdk.client.async.request.SaveReportAttachmentsRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.BaseInputControlsRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.CacheableRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.GetInputControlsRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.GetInputControlsValuesRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.GetReportRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.GetResourceLookupsRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.GetResourceRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.GetResourcesRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.GetServerInfoRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.SearchResourcesRequest.java
com.jaspersoft.android.sdk.client.async.request.cacheable.ValidateInputControlsValuesRequest.java
com.jaspersoft.android.sdk.client.async.task.DeleteResourceAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.GetInputControlsAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.GetReportAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.GetResourceAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.GetResourcesListAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.GetServerInfoAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.JsAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.JsRestAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.ModifyResourceAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.SaveReportAttachmentAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.SaveReportAttachmentsAsyncTask.java
com.jaspersoft.android.sdk.client.async.task.SearchResourcesAsyncTask.java
com.jaspersoft.android.sdk.client.ic.InputControlWrapper.java
com.jaspersoft.android.sdk.client.oxm.ReportAttachment.java
com.jaspersoft.android.sdk.client.oxm.ReportDescriptor.java
com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor.java
com.jaspersoft.android.sdk.client.oxm.ResourceParameter.java
com.jaspersoft.android.sdk.client.oxm.ResourceProperty.java
com.jaspersoft.android.sdk.client.oxm.ResourcesList.java
com.jaspersoft.android.sdk.client.oxm.control.InputControlOption.java
com.jaspersoft.android.sdk.client.oxm.control.InputControlState.java
com.jaspersoft.android.sdk.client.oxm.control.InputControlStatesList.java
com.jaspersoft.android.sdk.client.oxm.control.InputControl.java
com.jaspersoft.android.sdk.client.oxm.control.InputControlsList.java
com.jaspersoft.android.sdk.client.oxm.control.validation.DateTimeFormatValidationRule.java
com.jaspersoft.android.sdk.client.oxm.control.validation.MandatoryValidationRule.java
com.jaspersoft.android.sdk.client.oxm.control.validation.ValidationRule.java
com.jaspersoft.android.sdk.client.oxm.control.validation.ValidationRulesList.java
com.jaspersoft.android.sdk.client.oxm.converter.ReportStatusConverter.java
com.jaspersoft.android.sdk.client.oxm.report.ErrorDescriptor.java
com.jaspersoft.android.sdk.client.oxm.report.ExecutionRequest.java
com.jaspersoft.android.sdk.client.oxm.report.ExportExecution.java
com.jaspersoft.android.sdk.client.oxm.report.ExportsRequest.java
com.jaspersoft.android.sdk.client.oxm.report.FolderDataResponse.java
com.jaspersoft.android.sdk.client.oxm.report.ReportDataResponse.java
com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest.java
com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse.java
com.jaspersoft.android.sdk.client.oxm.report.ReportOutputResource.java
com.jaspersoft.android.sdk.client.oxm.report.ReportParameter.java
com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList.java
com.jaspersoft.android.sdk.client.oxm.report.ReportStatusResponse.java
com.jaspersoft.android.sdk.client.oxm.report.ReportStatus.java
com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupSearchCriteria.java
com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup.java
com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupsList.java
com.jaspersoft.android.sdk.client.oxm.server.ServerInfo.java
com.jaspersoft.android.sdk.integration.CheckReportStatusRequestTest.java
com.jaspersoft.android.sdk.integration.GetRootFolderDataRequestTest.java
com.jaspersoft.android.sdk.integration.ReportDetailsRequestTest.java
com.jaspersoft.android.sdk.integration.RunReportExportsRequestTest.java
com.jaspersoft.android.sdk.integration.utils.ProtoInstrumentation.java
com.jaspersoft.android.sdk.integration.utils.SampleData.java
com.jaspersoft.android.sdk.ui.adapters.FileArrayAdapter.java
com.jaspersoft.android.sdk.ui.adapters.ResourceDescriptorArrayAdapter.java
com.jaspersoft.android.sdk.ui.adapters.ResourceDescriptorComparator.java
com.jaspersoft.android.sdk.ui.adapters.ResourceLookupArrayAdapter.java
com.jaspersoft.android.sdk.ui.adapters.ResourceLookupComparator.java
com.jaspersoft.android.sdk.ui.adapters.ResourceLookupEndlessAdapter.java
com.jaspersoft.android.sdk.ui.adapters.ResourcePropertyArrayAdapter.java
com.jaspersoft.android.sdk.ui.widget.MultiSelectSpinner.java
com.jaspersoft.android.sdk.util.CookieHttpRequestInterceptor.java
com.jaspersoft.android.sdk.util.FileUtils.java
com.jaspersoft.android.sdk.util.KeepAliveHttpRequestInterceptor.java
com.jaspersoft.android.sdk.util.LocalesHttpRequestInterceptor.java
com.jaspersoft.android.sdk.util.StaticCacheHelper.java