The Briefcase Engine offers collections of content instances that can be shared among multiple users. Briefcase contents can also be queried using the search engine, using a custom filter.
The basic workflow when working with briefcases is as follows:
Create a new briefcase using
BriefcaseEngine#create
.
When the ACL parameter is
null
,
the briefcase can only be seen by the user that created it. Otherwise the
ACL
determines the user groups who can see and edit the briefcase.
Use the briefcase ID returned in the previous step to populate the briefcase with content instances using BriefcaseEngine#addItems .
You can associate metadata with briefcase items (for example, a flag to indicate some kind of action performed on the briefcase item) in the form of key-value pairs. This information is specific to the briefcase item and does not affect the content instance at all.
Metadata can be selected from a briefcase in a FxSQL query with the
@metadata
column.
Metadata cannot, however, be queried, i.e. it cannot be part of the
WHERE
clause. If you need queryable metadata, you should think about using
some kind of relation type (i.e. an intermediary type with a reference to the actual content).
To access values of the content instances of a briefcase, use the FxSQL interface. For example, this statement selects the primary key and the caption of the items of the briefcase with ID 21:
SELECT @pk, caption FILTER briefcase=21
Note that you can also query the content instances inside a briefcase, i.e. you
can specify a
WHERE
clause and further restrict the result set.
Example 6.20. Working with briefcases and metadata
final BriefcaseEngine be = EJBLookup.getBriefcaseEngine(); // create a new briefcase final int briefcaseId = be.create("test", "description", /* ACL */ null); // get PKs of all visible folders final FxResultSet result = new SqlQueryBuilder().select("@pk").type("FOLDER").getResult(); final List<FxPK> folders = result.collectColumn(1); assert !folders.isEmpty(); // add to briefcase be.addItems(briefcaseId, folders); assert be.load(briefcaseId).getSize() == folders.size(); // add some metadata for this briefcase for the first folder final FxReferenceMetaData<FxPK> meta = FxReferenceMetaData.createNew(folders.get(0)); meta.put("processed", "false"); be.mergeMetaData(briefcaseId, Arrays.asList(meta)); // select briefcase contents final FxResultSet items = new SqlQueryBuilder().select("@pk", "caption", "@metadata") .filterBriefcase(briefcaseId) .getResult(); assert items.getRowCount() == folders.size(); // get metadata from FxSQL result set final List<FxReferenceMetaData<FxPK>> resultMeta = items.collectColumn(3); // check if our "processed" flag set above was preserved assert false == FxReferenceMetaData.findByContent( resultMeta, meta.getReference() ).getBoolean( "processed", /* default */ true );