This chapter describes methods provided by Stardust to retrieve model version tree information.
The class DeployedModelQuery provides functionality to query the model repository.
The method findAll() initiates a query to find all deployed models.
public static DeployedModelQuery findAll()
{
return new DeployedModelQuery();
}
The return type is the configured query.
To create a query to find all active models, use the method
findActive(). For a description on the model state
Active refer to section
Active
of the chapter
Model States.
public static DeployedModelQuery findActive()
{
DeployedModelQuery query = new DeployedModelQuery();
query.where(STATE.isEqual(DeployedModelState.ACTIVE.name()));
return query;
}
The return type is the configured query. This method can be used as a
shortcut for
findInState(DeployedModelState.ACTIVE).
To find the active deployed model with a given Id, use method
findActiveForId(String modelId).
public static DeployedModelQuery findActiveForId(String modelId)
{
DeployedModelQuery query = new DeployedModelQuery();
query.where(ID.isEqual(modelId)).and(STATE.isEqual(DeployedModelState.ACTIVE.name()));
return query;
}
The return type is the configured query.
In case you want to retrieve all deployed models currently
being in a specified state, use the method
findInState(DeployedModelState modelState).
public static DeployedModelQuery findInState(
DeployedModelState modelState)
{
DeployedModelQuery query = new DeployedModelQuery();
query.where(STATE.isEqual(modelState.name()));
return query;
}
The parameter modelState defines the state the model should be in.
Please refer to the chapter
Model States for details
of possible model states and their description. Return type is the
configured query.
The method findForId(String modelId provides a query
to find all model versions having the given model ID.
public static DeployedModelQuery findForId(String modelId)
{
DeployedModelQuery query = new DeployedModelQuery();
query.where(ID.isEqual(modelId));
return query;
}
The parameter modelId specifies the ID of the models
to retrieve the model versions of. The return type is the configured query.
To retrieve all models referenced by a given model, the
method findUsedBy(long modelOid).
public static DeployedModelQuery findUsedBy(long modelOid)
{
DeployedModelQuery query = new DeployedModelQuery();
query.where(CONSUMER.isEqual(modelOid));
return query;
}
The model OID of the referencing model is given via the parameter
modelId. The return type is the configured query.
The method findUsing(long modelOid) provides a query
for all models referencing a given model.
public static DeployedModelQuery findUsing(long modelOid)
{
DeployedModelQuery query = new DeployedModelQuery();
query.where(PROVIDER.isEqual(modelOid));
return query;
}
Parameter modelId determines the model OID of the referenced model.
The return type is the configured query.
You can filter models based on the OID attribute via:
public static final FilterableAttribute OID = new FilterableAttributeImpl(DeployedModelQuery.class, "oid");
For example use the following code to get a range of models:
DeployedModelQuery query = new DeployedModelQuery(); query.where(OID.between(2, 5));
You can filter models based on the ID attribute via:
public static final FilterableAttribute ID = new FilterableAttributeImpl(DeployedModelQuery.class, "id");
For example use the following SQL style pattern to get a range of models:
DeployedModelQuery query = new DeployedModelQuery();
query.where(ID.like("%AN%"));
You can filter models based on the STATE attribute via:
public static final FilterableAttribute STATE = new FilterableAttributeImpl(DeployedModelQuery.class, "state");
For example use the following code to get all valid models with a specific Id:
DeployedModelQuery query = new DeployedModelQuery();
query.where(ID.isEqual(modelId)).and(STATE.isEqual("VALID"));
You can filter models based on references to a specific model.:
public static final FilterableAttribute PROVIDER = new FilterableAttributeImpl(DeployedModelQuery.class, "provider");
or
public static final FilterableAttribute CONSUMER = new FilterableAttributeImpl(DeployedModelQuery.class, "consumer");
For example use the following code to get all models using a specific one:
DeployedModelQuery query = new DeployedModelQuery(); query.where(PROVIDER.isEqual(modelOid));
The following example provides code to get all models used by a specific one:
DeployedModelQuery query = new DeployedModelQuery(); query.where(CONSUMER(modelOid));
If you like to enforce the DeployedModelQuery to exclude the deployed predefined model, you can use the provided ModelPolicy.
For example:
DeployedModelQuery query = DeployedModelQuery.findAll(); query.setPolicy(ModelPolicy.excludePredefinedModels());
For details on using policies, refer to section Using Policies of chapter Building Queries.