Package org.intermine.api.template
Class TemplatePopulator
- java.lang.Object
-
- org.intermine.api.template.TemplatePopulator
-
public final class TemplatePopulator extends java.lang.Object
Configures original template. Old constraints are replaced with the similar new constraints, that have different values.- Author:
- Richard Smith
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TemplateQuery
getPopulatedTemplate(TemplateQuery origTemplate, java.util.Map<java.lang.String,java.util.List<TemplateValue>> newConstraints)
Given a template and a map of values for editable constraints on each editable node create a copy of the template query with the values filled in.static TemplateQuery
populateTemplateOneConstraint(TemplateQuery template, ConstraintOp op, java.lang.String value)
Populate a TemplateQuery that has a single editable constraint with the given value.static TemplateQuery
populateTemplateWithBag(TemplateQuery template, InterMineBag bag)
Constrain a template query with a single editable constraint to be in the given bag.static TemplateQuery
populateTemplateWithObject(TemplateQuery template, InterMineObject obj)
Constrain a template query with a single editable constraint to be the given object.protected static void
setConstraint(TemplateQuery template, TemplateValue templateValue)
Set the value for a constraint in the template query with the given TemplateValue.
-
-
-
Method Detail
-
getPopulatedTemplate
public static TemplateQuery getPopulatedTemplate(TemplateQuery origTemplate, java.util.Map<java.lang.String,java.util.List<TemplateValue>> newConstraints)
Given a template and a map of values for editable constraints on each editable node create a copy of the template query with the values filled in. This may alter the query when e.g. bag constraints are applied to a class rather than an attribute.- Parameters:
origTemplate
- the template to populate with valuesnewConstraints
- a map from editable node to a list of values for each editable constraint- Returns:
- a copy of the template with values filled in
- Throws:
TemplatePopulatorException
- if something goes wrong
-
populateTemplateWithObject
public static TemplateQuery populateTemplateWithObject(TemplateQuery template, InterMineObject obj) throws PathException
Constrain a template query with a single editable constraint to be the given object. This returns a copy of the template with the value filled in, if the existing constraint will be replaced by a constraint on the id field of the editable node.- Parameters:
template
- the template to constrainobj
- the object to constrain to- Returns:
- a copy of the template with values filled in
- Throws:
PathException
- if the template is invalid
-
populateTemplateWithBag
public static TemplateQuery populateTemplateWithBag(TemplateQuery template, InterMineBag bag) throws PathException
Constrain a template query with a single editable constraint to be in the given bag. This returns a copy of the template with the value filled in, if the constraint is on an attribute it will be replaced by a constrain on the parent class.- Parameters:
template
- the template to constrainbag
- the bag to constrain to- Returns:
- a copy of the template with values filled in
- Throws:
PathException
- if the template is invalid
-
populateTemplateOneConstraint
public static TemplateQuery populateTemplateOneConstraint(TemplateQuery template, ConstraintOp op, java.lang.String value) throws PathException
Populate a TemplateQuery that has a single editable constraint with the given value. This returns a copy of the template with the value filled in.- Parameters:
template
- the template query to populateop
- operation of the constraintvalue
- value to be constrained to- Returns:
- a copy of the template with the value filled in
- Throws:
PathException
- if the template is invalid
-
setConstraint
protected static void setConstraint(TemplateQuery template, TemplateValue templateValue) throws PathException
Set the value for a constraint in the template query with the given TemplateValue. This may move a constraint from an attribute to the parent class if the constraint is object or bag.- Parameters:
template
- the template to constraintemplateValue
- container for the value to set constraint to- Throws:
PathException
- if a TemplateValue contains an invalid path
-
-