strolch/li.strolch.service/src/main/java/li/strolch/report/policy/GenericReport.java

529 lines
17 KiB
Java
Raw Normal View History

package li.strolch.report.policy;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
import static java.util.Comparator.comparingInt;
import static li.strolch.report.ReportConstants.*;
2017-10-27 19:22:22 +02:00
import static li.strolch.utils.helper.StringHelper.EMPTY;
2017-03-21 07:51:13 +01:00
import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collector;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
import java.util.stream.Collectors;
import java.util.stream.Stream;
import li.strolch.agent.api.ComponentContainer;
import li.strolch.model.*;
import li.strolch.model.parameter.*;
import li.strolch.model.policy.PolicyDef;
import li.strolch.model.visitor.ElementDateVisitor;
import li.strolch.model.visitor.ElementStateVisitor;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
import li.strolch.persistence.api.StrolchTransaction;
import li.strolch.policy.PolicyHandler;
import li.strolch.report.ReportElement;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
import li.strolch.runtime.StrolchConstants;
import li.strolch.utils.ObjectHelper;
import li.strolch.utils.collections.DateRange;
2017-03-21 07:51:13 +01:00
import li.strolch.utils.collections.MapOfSets;
import li.strolch.utils.iso8601.ISO8601FormatFactory;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
/**
* @author Robert von Burg &lt;eitch@eitchnet.ch&gt;
*/
public class GenericReport extends ReportPolicy {
2017-03-21 07:51:13 +01:00
private Resource reportRes;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
private boolean hideObjectTypeFromFilterCriteria;
private String objectType;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
private ParameterBag columnsBag;
private List<StringParameter> orderingParams;
private boolean descending;
2017-10-27 19:22:22 +02:00
private boolean allowMissingColumns;
private List<String> columnIds;
private StringParameter dateRangeSelP;
private DateRange dateRange;
private Map<ReportFilterPolicy, StringParameter> filtersByPolicy;
private MapOfSets<String, String> filtersById;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
public GenericReport(ComponentContainer container, StrolchTransaction tx) {
super(container, tx);
}
public void initialize(String reportId) {
// get the reportRes
this.reportRes = tx().getResourceBy(TYPE_REPORT, reportId, true);
BooleanParameter hideObjectTypeFromFilterCriteriaP = this.reportRes
.getParameter(BAG_PARAMETERS, PARAM_HIDE_OBJECT_TYPE_FROM_FILTER_CRITERIA);
this.hideObjectTypeFromFilterCriteria =
hideObjectTypeFromFilterCriteriaP != null && hideObjectTypeFromFilterCriteriaP.getValue();
if (this.hideObjectTypeFromFilterCriteria) {
this.objectType = this.reportRes.getParameter(BAG_PARAMETERS, PARAM_OBJECT_TYPE).getValue();
}
this.columnsBag = this.reportRes.getParameterBag(BAG_COLUMNS, true);
this.columnIds = this.columnsBag.getParameters().stream() //
.sorted(comparingInt(Parameter::getIndex)) //
.map(StrolchElement::getId) //
.collect(Collectors.toList());
if (this.reportRes.hasParameter(BAG_PARAMETERS, PARAM_DESCENDING))
this.descending = this.reportRes.getParameter(BAG_PARAMETERS, PARAM_DESCENDING).getValue();
2017-10-27 19:22:22 +02:00
if (this.reportRes.hasParameter(BAG_PARAMETERS, PARAM_ALLOW_MISSING_COLUMNS))
this.allowMissingColumns = this.reportRes.getParameter(BAG_PARAMETERS, PARAM_ALLOW_MISSING_COLUMNS)
.getValue();
this.dateRangeSelP = this.reportRes.getParameter(BAG_PARAMETERS, PARAM_DATE_RANGE_SEL);
// evaluate ordering params
if (this.reportRes.hasParameterBag(BAG_ORDERING)) {
ParameterBag orderingBag = this.reportRes.getParameterBag(BAG_ORDERING);
if (orderingBag.hasParameters()) {
this.orderingParams = orderingBag.getParameters().stream().map(e -> (StringParameter) e)
.collect(Collectors.toList());
this.orderingParams.sort(comparingInt(AbstractParameter::getIndex));
}
}
// evaluate filters
this.filtersByPolicy = new HashMap<>();
List<ParameterBag> filterBags = this.reportRes.getParameterBagsByType(TYPE_FILTER);
for (ParameterBag filterBag : filterBags) {
// prepare filter function policy
StringParameter functionP = filterBag.getParameter(PARAM_POLICY);
PolicyHandler policyHandler = getContainer().getComponent(PolicyHandler.class);
PolicyDef policyDef = PolicyDef.valueOf(functionP.getInterpretation(), functionP.getUom());
ReportFilterPolicy filterFunction = policyHandler.getPolicy(policyDef, tx());
filterFunction.init(functionP.getValue());
StringParameter fieldRefP = filterBag.getParameter(PARAM_FIELD_REF);
this.filtersByPolicy.put(filterFunction, fieldRefP);
}
}
public boolean hasDateRangeSelector() {
return this.dateRangeSelP != null;
}
public GenericReport dateRange(DateRange dateRange) {
this.dateRange = dateRange;
return this;
2017-03-21 07:51:13 +01:00
}
public List<String> getColumnKeys() {
return this.columnIds;
}
2017-03-21 07:51:13 +01:00
public GenericReport filter(String type, String... ids) {
if (this.filtersById == null)
this.filtersById = new MapOfSets<>();
2017-03-21 07:51:13 +01:00
for (String id : ids) {
this.filtersById.addElement(type, id);
2017-03-21 07:51:13 +01:00
}
return this;
}
public GenericReport filter(String type, List<String> ids) {
if (this.filtersById == null)
this.filtersById = new MapOfSets<>();
2017-03-21 07:51:13 +01:00
for (String id : ids) {
this.filtersById.addElement(type, id);
2017-03-21 07:51:13 +01:00
}
return this;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
}
public GenericReport filter(String type, Set<String> ids) {
if (this.filtersById == null)
this.filtersById = new MapOfSets<>();
for (String id : ids) {
this.filtersById.addElement(type, id);
}
return this;
}
public Stream<Map<String, StrolchRootElement>> buildStream() {
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
// query the main objects and return a stream
Stream<Map<String, StrolchRootElement>> stream = queryRows().map(this::evaluateRow);
if (hasFilter())
stream = stream.filter(this::filter);
if (hasOrdering())
stream = stream.sorted(this::sort);
return stream;
2017-03-21 07:51:13 +01:00
}
public Stream<ReportElement> doReport() {
return buildStream().map(e -> new ReportElement(this.columnIds, columnId -> {
StringParameter columnDefP = this.columnsBag.getParameter(columnId, true);
Object value = evaluateColumnValue(columnDefP, e);
if (value instanceof Date)
return ISO8601FormatFactory.getInstance().formatDate((Date) value);
if (value instanceof Parameter)
return ((Parameter) value).getValueAsString();
return value.toString();
}));
}
protected boolean filterCriteria(StrolchRootElement element) {
if (this.hideObjectTypeFromFilterCriteria)
return !element.getType().equals(this.objectType);
return true;
}
public MapOfSets<String, StrolchRootElement> generateFilterCriteria() {
return buildStream() //
.flatMap(e -> e.values().stream().filter(this::filterCriteria)) //
.collect( //
Collector.of( //
(Supplier<MapOfSets<String, StrolchRootElement>>) MapOfSets::new, //
(m, e) -> m.addElement(e.getType(), e), //
MapOfSets::addAll, //
m -> m));
}
protected boolean hasOrdering() {
return this.orderingParams != null && !this.orderingParams.isEmpty();
}
protected int sort(Map<String, StrolchRootElement> row1, Map<String, StrolchRootElement> row2) {
for (StringParameter fieldRefP : this.orderingParams) {
String type = fieldRefP.getUom();
StrolchRootElement column1 = row1.get(type);
2017-10-27 19:22:22 +02:00
StrolchRootElement column2 = row2.get(type);
if (column1 == null && column2 == null)
continue;
if (column1 == null)
return -1;
if (column2 == null)
return 1;
int sortVal;
if (fieldRefP.getValue().startsWith("$")) {
Object columnValue1 = evaluateColumnValue(fieldRefP, row1);
Object columnValue2 = evaluateColumnValue(fieldRefP, row2);
if (this.descending) {
sortVal = ObjectHelper.compare(columnValue1, columnValue2, true);
} else {
sortVal = ObjectHelper.compare(columnValue2, columnValue1, true);
}
} else {
2017-10-27 19:22:22 +02:00
Optional<Parameter<?>> param1 = lookupParameter(fieldRefP, column1);
Optional<Parameter<?>> param2 = lookupParameter(fieldRefP, column2);
if (!param1.isPresent() && !param2.isPresent())
continue;
if (param1.isPresent() && !param2.isPresent())
return 1;
else if (!param1.isPresent())
return -1;
if (this.descending)
2017-10-27 19:22:22 +02:00
sortVal = param1.get().compareTo(param2.get());
else
2017-10-27 19:22:22 +02:00
sortVal = param2.get().compareTo(param1.get());
}
if (sortVal != 0)
return sortVal;
}
return 0;
}
protected boolean hasFilter() {
return !this.filtersByPolicy.isEmpty() || this.dateRange != null || (this.filtersById != null
&& !this.filtersById.isEmpty());
}
protected boolean filter(Map<String, StrolchRootElement> row) {
2017-03-21 07:51:13 +01:00
// do filtering by policies
for (ReportFilterPolicy filterPolicy : this.filtersByPolicy.keySet()) {
StringParameter fieldRefP = this.filtersByPolicy.get(filterPolicy);
String type = fieldRefP.getUom();
StrolchRootElement column = row.get(type);
// if column is null, then don't include in result
if (column == null)
return false;
if (fieldRefP.getValue().startsWith("$")) {
Object value = evaluateColumnValue(fieldRefP, row);
if (!filterPolicy.filter(value))
return false;
} else {
2017-10-27 19:22:22 +02:00
Optional<Parameter<?>> param = lookupParameter(fieldRefP, column);
if (param.isPresent() && !filterPolicy.filter(param.get()))
return false;
}
}
// do a date range selection, if required
if (this.dateRange != null) {
if (this.dateRangeSelP == null)
throw new IllegalStateException(
"DateRange defined, but reportRes does not defined a date range selector!");
String type = this.dateRangeSelP.getUom();
2017-03-21 07:51:13 +01:00
StrolchRootElement element = row.get(type);
if (element == null)
return false;
String dateRangeSel = this.dateRangeSelP.getValue();
Date date;
if (dateRangeSel.equals(COL_DATE)) {
date = element.accept(new ElementDateVisitor());
} else {
2017-10-27 19:22:22 +02:00
Optional<Parameter<?>> param = lookupParameter(this.dateRangeSelP, element);
if (!param.isPresent() || StrolchValueType.parse(param.get().getType()) != StrolchValueType.DATE)
throw new IllegalStateException(
2017-10-27 19:22:22 +02:00
"Date Range selector is invalid, as referenced parameter is not a Date but " + (param
.isPresent() ? param.get().getType() : "null"));
2017-10-27 19:22:22 +02:00
date = ((DateParameter) param.get()).getValue();
}
if (!this.dateRange.contains(date))
2017-03-21 07:51:13 +01:00
return false;
}
// then we do a filter by criteria
if (this.filtersById != null && !this.filtersById.isEmpty()) {
for (String type : this.filtersById.keySet()) {
StrolchRootElement element = row.get(type);
if (element == null)
return false;
if (!this.filtersById.getSet(type).contains(element.getId()))
return false;
}
}
// otherwise we want to keep this row
2017-03-21 07:51:13 +01:00
return true;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
}
protected Object evaluateColumnValue(StringParameter columnDefP, Map<String, StrolchRootElement> row) {
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
String columnDef = columnDefP.getValue();
String refType = columnDefP.getUom();
// get the referenced object
StrolchRootElement column = row.get(refType);
Object columnValue;
if (column == null) {
2017-10-27 19:22:22 +02:00
columnValue = EMPTY;
} else if (columnDef.equals(COL_OBJECT)) {
columnValue = column;
} else if (columnDef.equals(COL_ID)) {
columnValue = column.getId();
} else if (columnDef.equals(COL_NAME)) {
columnValue = column.getName();
} else if (columnDef.equals(COL_TYPE)) {
columnValue = column.getType();
} else if (columnDef.equals(COL_STATE)) {
columnValue = column.accept(new ElementStateVisitor());
} else if (columnDef.equals(COL_DATE)) {
columnValue = column.accept(new ElementDateVisitor());
} else if (columnDef.startsWith(COL_SEARCH)) {
Parameter<?> parameter = findParameter(columnDefP, column);
if (parameter == null)
2017-10-27 19:22:22 +02:00
columnValue = EMPTY;
else
columnValue = parameter;
} else {
columnValue = lookupParameter(columnDefP, column).orElseGet(StringParameter::new);
}
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
return columnValue;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
}
protected Parameter<?> findParameter(StringParameter columnDefP, StrolchRootElement column) {
String columnDef = columnDefP.getValue();
String[] searchParts = columnDef.split(SEARCH_SEPARATOR);
if (searchParts.length != 3)
throw new IllegalStateException(
"Parameter search reference (" + columnDef + ") is invalid as it does not have 3 parts for "
+ columnDefP.getLocator());
String parentParamId = searchParts[1];
String paramRef = searchParts[2];
String[] locatorParts = paramRef.split(Locator.PATH_SEPARATOR);
if (locatorParts.length != 3)
throw new IllegalStateException(
"Parameter search reference (" + paramRef + ") is invalid as it does not have 3 parts for "
+ columnDefP.getLocator());
String bagKey = locatorParts[1];
String paramKey = locatorParts[2];
return findParameter(column, parentParamId, bagKey, paramKey);
}
protected Parameter<?> findParameter(StrolchRootElement element, String parentParamId, String bagKey,
String paramKey) {
Parameter<?> parameter = element.getParameter(bagKey, paramKey);
if (parameter != null)
return parameter;
StringParameter parentRefP = element.getParameter(BAG_RELATIONS, parentParamId);
if (parentRefP == null)
return null;
Resource parent = tx().getResourceBy(parentRefP);
if (parent == null)
return null;
return findParameter(parent, parentParamId, bagKey, paramKey);
}
2017-10-27 19:22:22 +02:00
protected Optional<Parameter<?>> lookupParameter(StringParameter paramRefP, StrolchRootElement column) {
String paramRef = paramRefP.getValue();
String[] locatorParts = paramRef.split(Locator.PATH_SEPARATOR);
if (locatorParts.length != 3)
throw new IllegalStateException(
"Parameter reference (" + paramRef + ") is invalid as it does not have 3 parts for " + paramRefP
.getLocator());
String bagKey = locatorParts[1];
String paramKey = locatorParts[2];
Parameter<?> param = column.getParameter(bagKey, paramKey);
2017-10-27 19:22:22 +02:00
if (!allowMissingColumns && param == null)
throw new IllegalStateException(
"Parameter reference (" + paramRef + ") for " + paramRefP.getLocator() + " not found on " + column
.getLocator());
2017-10-27 19:22:22 +02:00
return Optional.ofNullable(param);
}
protected Stream<? extends StrolchRootElement> queryRows() {
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
StringParameter objectTypeP = this.reportRes.getParameter(BAG_PARAMETERS, PARAM_OBJECT_TYPE);
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
// find the type of object for which the reportRes is created
switch (objectTypeP.getInterpretation()) {
case StrolchConstants.INTERPRETATION_RESOURCE_REF:
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
return tx().streamResources(objectTypeP.getUom());
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
case StrolchConstants.INTERPRETATION_ORDER_REF:
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
return tx().streamOrders(objectTypeP.getUom());
case StrolchConstants.INTERPRETATION_ACTIVITY_REF:
return tx().streamActivities(objectTypeP.getUom());
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
default:
throw new IllegalArgumentException("Unhandled element type " + objectTypeP.getInterpretation());
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
}
}
protected Map<String, StrolchRootElement> evaluateRow(StrolchRootElement resource) {
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
// interpretation -> Resource-Ref, etc.
// uom -> object type
// value -> element type where relation is defined for this join
// create the refs element
HashMap<String, StrolchRootElement> refs = new HashMap<>();
// and add the starting point
refs.put(resource.getType(), resource);
if (!this.reportRes.hasParameterBag(BAG_JOINS))
return refs;
ParameterBag joinBag = this.reportRes.getParameterBag(BAG_JOINS);
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
for (String paramId : joinBag.getParameterKeySet()) {
StringParameter joinP = joinBag.getParameter(paramId);
addColumnJoin(refs, joinBag, joinP, true);
}
return refs;
}
protected StrolchRootElement addColumnJoin(Map<String, StrolchRootElement> refs, ParameterBag joinBag,
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
StringParameter joinP, boolean optional) {
String interpretation = joinP.getInterpretation();
String elementType = interpretation.substring(0, interpretation.indexOf(SUFFIX_REF));
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
String joinType = joinP.getUom();
String dependencyType = joinP.getValue();
// get dependency
StrolchRootElement dependency;
if (refs.containsKey(dependencyType)) {
dependency = refs.get(dependencyType);
} else {
// recursively find the dependency
StringParameter dependencyP = joinBag.getParameter(dependencyType);
dependency = addColumnJoin(refs, joinBag, dependencyP, false);
if (dependency == null)
return null;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
}
ParameterBag relationsBag = dependency.getParameterBag(BAG_RELATIONS);
if (relationsBag == null)
throw new IllegalStateException(
"Invalid join definition value: " + joinP.getValue() + " on: " + joinP.getLocator() + " as "
+ dependency.getLocator() + " has no ParameterBag " + BAG_RELATIONS);
List<Parameter<?>> relationParams = relationsBag.getParametersByInterpretationAndUom(interpretation, joinType)
.stream().filter(p -> p.getValueType() == StrolchValueType.STRING).collect(Collectors.toList());
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
if (relationParams.isEmpty()) {
throw new IllegalStateException(
"Found no relation parameters with UOM " + joinType + " of type " + StrolchValueType.STRING
.getType() + " on dependency " + dependency.getLocator());
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
}
if (relationParams.size() > 1) {
throw new IllegalStateException(
"Found multiple possible relation parameters for UOM " + joinType + " on dependency " + dependency
.getLocator());
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
}
Parameter<?> relationParam = relationParams.get(0);
StringParameter relationP = (StringParameter) relationParam;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
if (relationP.getValue().isEmpty() && optional) {
return null;
}
Locator locator = Locator.valueOf(elementType, joinType, relationP.getValue());
StrolchRootElement joinElem = tx().findElement(locator, true);
if (joinElem == null)
return null;
[New] Added new generic report creator Create a Report as follows: <Resource Id="stockReport" Name="Stock Report" Type="Report"> <ParameterBag Id="parameters" Name="parameters" Type="Parameters"> <Parameter Id="objectType" Name="Object Type" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Slot" /> </ParameterBag> <ParameterBag Id="columns" Name="Display Columns" Type="Display"> <Parameter Id="location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="$name" /> <Parameter Id="storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="$name" /> <Parameter Id="section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="$name" /> <Parameter Id="slot" Name="Slot" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="$name" /> <Parameter Id="product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="$name" /> <Parameter Id="quantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/quantity" /> <Parameter Id="maxQuantity" Name="Quantity" Type="String" Interpretation="Resource-Ref" Uom="Slot" Value="Bags/parameters/maxQuantity" /> </ParameterBag> <ParameterBag Id="joins" Name="Joins" Type="Joins"> <Parameter Id="Product" Name="Product" Type="String" Interpretation="Resource-Ref" Uom="Product" Value="Slot" /> <Parameter Id="Section" Name="Section" Type="String" Interpretation="Resource-Ref" Uom="Section" Value="Slot" /> <Parameter Id="Storage" Name="Storage" Type="String" Interpretation="Resource-Ref" Uom="Storage" Value="Section" /> <Parameter Id="Location" Name="Location" Type="String" Interpretation="Resource-Ref" Uom="Location" Value="Storage" /> </ParameterBag> </Resource> This creates a report for objects of type Slot, where a Join is done on multiple objects: Slot -> Product -> Section -> Storage -> Location Thus the columns can then be fetched from different joing objects. The joing is done by searching for a Parameter on the joined object on the ParameterBag "relations". See the example XML on how this is done. Or ask eitch@eitchnet.ch to write a proper documentation =)) Filtering is missing, and will be added later
2017-03-20 19:27:59 +01:00
refs.put(joinType, joinElem);
return joinElem;
}
}