This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In Querying resources you will be working on the "REG_RESOURCE" table. "REG_RESOURCE" table contains the following fields:

  • REG_RESOURCE
  • REG_PATH_ID
  • REG_NAME
  • REG_VERSION
  • REG_MEDIA_TYPE
  • REG_CREATOR
  • REG_CREATED_TIME
  • REG_LAST_UPDATOR
  • REG_LAST_UPDATED_TIME
  • REG_DESCRIPTION
  • REG_CONTENT_ID

In order to return a resource, you always need to return the "REG_PATH_ID, REG_NAME" in your custom query. This is because ("REG_PATH_ID, REG_NAME") fields act together as an ID for the resource.

For example, the following query will return one or more resources that have a given pattern in the description:

SELECT REG_PATH_ID, REG_NAME FROM REG_RESOURCE WHERE REG_DESCRIPTION LIKE?

The following example shows a code snippet that does a custom query.

1. Put a resource with the content as the query.

String sql1 = "SELECT REG_PATH_ID, REG_NAME FROM REG_RESOURCE WHERE REG_DESCRIPTION LIKE ?";

Resource q1 = registry.newResource();

q1.setContent(sql1);

q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);

q1.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,

RegistryConstants.RESOURCES_RESULT_TYPE);

registry.put(RegistryConstants.CONFIG_REGISTRY_BASE_PATH + RegistryConstants.QUERIES_COLLECTION_PATH + "/custom-queries", q1);

2. Give the parameters and the query location you have just putted.

Map parameters = new HashMap();

parameters.put("1", "%service%");

Resource result = registry.executeQuery(RegistryConstants.CONFIG_REGISTRY_BASE_PATH + RegistryConstants.QUERIES_COLLECTION_PATH + "/custom-queries", parameters);

String\[\] paths = (String\[\])result.getContent();

For more information about Queries see Custom Query.

  • No labels