21 March 2016

1. File Package Download

The file package download, referred to FPD further on in this document, is a feature of the Office Integration component, which allows downloading multiple files in a so called package to a folder in the client’s computer and to automatically open a pre-defined file from the package.

The files within such a package can consist of dynamic data from the ENOVIA™ database, and/or checked in files.

Downloading multiple files from a web-environment is normally not doable, without the need to download a compressed file (like a ZIP file) and then rely on a third party tool to uncompressed the files. Also, such kind of a solution does not solve the need for automatically open a file from the compressed archive. And the user would also need to find the file to be opened via the file-explorer or similar.

The FPD solution, will remove the need to rely on having any third party uncompressing tools as well as reducing the number of mouse clicks the user would need to perform in handling multiple files. The FPD functionality also supports the architecture (File Collaboration Architecture), meaning that it is capable of downloading business object files from local file stores.

The FPD functionality can be used for a broad different use cases. One of many examples is, being able to create reports where you have Excel templates containing macros that populate the spreadsheet based upon data retrieved from Matrix.

1.1. Usage Scenario

The usage scenario depends on how the FPD functionality is configured. Mainly, there are two different usage scenarios: Starting without a pre-defined configuration or starting with a pre-defined configuration.

The user initiates the FPD by clicking on a link somewhere in the application, either from a command in a toolbar, through a standard link in the user interface or through another mechanism.

Depending on how the href is constructed, the user will be asked to select a configuration before the package is generated OR the link can be constructed so that the used configuration is defined directly in the href. In the later case, the user will not be prompted to select a configuration.

A configuration can be defined to require a single, none or multiple selected object(s) as input. The configuration defines what it needs. If the configuration declares that it requires selected objects as input, then the selected objects are validated against the configuration if they are accepted or not.

image
Figure 1. Selecting configuration

Once the user has selected the configuration, the system will start generating the package and the control of the package creation is handed over to the TVC File Manager client.

The client will periodically determine the status of the package creation, and once it’s done – it will start downloading the files into the target directory on the client’s computer. Once this is finished, the file that has been configured to be opened will be launched. If no file has been defined to be opened upon completion, the directory holding the package data will be opened for the user.

image
Figure 2. Downloading the Package

There are several other configuration options available; for example, one could have a pre-process page allowing the user to enter certain values before the actual data extraction is done.

1.2. Concepts

The FPD functionality is configured on the server side through a page object (admin object in business), which defines the behavior of a particular file package. This page object contains all different configurations that might exist in your environment.

For a configuration, the most central part is something called "Handler". The handler is responsible for defining the content of the package. For example, extracting meta-data from Matrix into different files, define dependent files needed to be checked out into the package from business object(s), add output from JPO execution(s) and more.

Typically, a Handler is a Java class, which is a part of the web-application. Writing such a handler is very simple, and gives the most flexible options. For less advanced use cases, one can instead of writing a Handler, use a pre-defined handler (see this section for further details), which does not require writing any Java code.

1.2.1. Command

This section describes how to create a Command to launch the File Package Download function from a TVC Structure Browser page or a business object’s details page.

Commands can be created and modified with the Business Administrator and MQL thick clients; however, it is recommended that you use the Business Administrator if you are not familiar with MQL (Matrix Query Language).

The most important parameter when creating a Command to launch the File Package Download is the "Href" parameter, whose value must be the following URL.

${ROOT_DIR}/tvc-action/fpd-init
When adding the command to a toolbar displayed in the standard Value Chain Portfolio applications it is sometimes necessary to append a bogus JSP page to the URL. E.g.
${ROOT_DIR}/tvc-action/fpd-init/foo.jsp
                               ^^^^^^^^

The reason for this is that when the toolbar is displayed in the Value Chain Portfolio application it fails to append the objectId parameter to the URL unless it ends with .jsp. This is not necessary if the command is to be added to the toolbar that is displayed on a TVC Structure Browser page.

1.2.2. Settings

The following table describes the settings and values that should be set on a Command that is used to launch the File Package Functionality.

Setting Description Required Value

Target Location

This setting defines the target frame when executing the command. The value should be set to "popup" to ensure that the File Package Dialog is loaded in a new popup window.

popup

Window Width

The width of the popup window. Recommended width is 500.

500

Window Height

The height of the popup window. Recommended height is 400.

400

In addition the following settings can be used when adding the command to the toolbar of a TVC Structure Browser page. Adding these settings will force the user to select a row in the table that will be the root business object when creating the File Package.

Setting Description Required Value

Row Select

Defines the required row selection on the TVC Structure Browser page when launching the Personal Browser.

single

Submit

Defines whether to submit the row selections or not when clicking on the Command.

true

1.2.3. Start with a Pre-Defined Configuration

Normally, when launching the command specified above, a dialog will appear with the possible configurations to be used (if any) where the user needs to select one of the configurations to be used in the particular use-case.

However, if desired, the file package functionality can be started directly with a defined configuration. You will need to add a parameter called configuration to the HREF, whose value is the id of a configuration (see the following chapters how to define a configuration and associate id’s to them).

2. Configuration

There are two ways to handle the configurations for the File Package Download functionality. The first way is to keep the configurations within a page object in the database called "TVC File Package Download Configuration". This page object can contain multiple configurations.

The other way is to store a configuration as an XML file within the application server, under the "/WEB-INF/tvc/fpd" folder. In the latter case, each configuration should be placed inside its own file.

It is possible to mix these two configuration storage alternatives.

2.1. Page Object

The page object called "TVC File Package Download Config" contains the configurations available.

The content of this page object is XML data, and follows this format:

<Configurations>
    <Configuration id="firstCfg">
        ...
    </Configuration>
    <Configuration id="secondCfg">
        ...
    </Configuration>
    ...
</Configurations>

The format/content for the "Configuration" element is described later on. Important to remember is that when the configurations are defined in the page-object, each configuration must have a unique id associated.

2.2. XML File

Since the number of configuration can grow to become quite large, the page object might be harder to maintain. An easier approach is to hold each configuration as a separate file (this is possible as of the 2009.1 release).

In this case, you don’t need the "Configurations" element as in the "page-object" case. Also, you don’t need to specify an "id" on the "Configuration" element, as the file-path acts as the id.

This approach makes it easier to deploy new FPD configurations also, since you don’t need to modify the database at all.

2.3. Configuration Format

An example of how such a configuration object is defined is shown below:

<!--
     Each configuration must have a unique id
     NOTE: not needed in case the configuration is stored in separate XML files
 -->
<Configuration id="cfg1"> (1)
    <!-- The name of this configuration. Can be localized -->
    <DisplayName>Test</DisplayName> (2)
    <DisplayName locale="sv">Test sv</DisplayName>

    <!-- The description of this configuration. Can be localized -->
    <Description>This is the descriptive text</Description> (3)

    <!--
         Defines the package name. If the package is made against an
         object, then the package name can consist of dynamic values, resolved
         from such object.
     -->
    <PackageName> (4)
        <Text>Test Package</Text>
        <Text>_</Text>
        <CurrentUser/>
        <Text>_</Text>
        <Date/>

        <!-- Example of dynamic values -->
        <Basic>current</Basic>
        <Text>_</Text>
        <Attribute>attribute_Test</Attribute>
    </PackageName>

    <!-- Define access to this configuration -->
    <Access> (5)
        <UserList>
            <User>A Person</User>
        </UserList>
        <RoleList>
            <Role>role_GlobalUser</Role>
        </RoleList>
        <GroupList>
            <Group>A Group</Group>
        </GroupList>
    </Access>

    <!--
         Defines the types, which this config is valid for
         Note: The valid-for is ignored, if the RowSelectType is
         set to none.
      -->
    <ValidFor> (6)
        <TypeList>
            <Type>type_Type</Type>
            <Type>type_AnotherType</Type>
        </TypeList>
    </ValidFor>

    <!-- Defines the kind of selections needed for this config to run -->
    <RowSelectType>none</RowSelectType> <!-- none | single | multiple --> (7)

    <!-- Defines a pre-processor -->
    <PreProcessor> (8)
        <Page>/path/to/a/JspPage/MyPage.jsp</Page> <!--Context relative path-->
    </PreProcessor>

    <!-- The handler is the key in the file package download functionality -->
    <Handler className="my.package.example.TestHandler"/> (9)
</Configuration>
1 Each configuration is defined inside the "Configuration" element. NOTE: The id must be defined, and must be unique across all defined configurations, since the id is used to refer to a unique configuration.
2 Defines the displayed name of the configuration. The name can be localized in different languages, by simply adding as many <DisplayName> elements you wish, with different locale attributes.
3 The description contains a more descriptive text for the user, when he/she is selecting the configuration to be used. As well as for the DisplayName, this element can also be localized in different languages.
4 Defines the name of the package. The package name will be used when the files are saved on the client’s computer, i.e. the package name is the name of the directory under which the files are being saved.
5 Defines the access to a particular configuration. Only configurations that a user has access to will show up in the drop-down list in the File Package Download configuration dialog.
6 When setting up a configuration it is possible to define for which object type (or types) a configuration should be available. See this chapter for further details.
7 Defines what kind of object selections required, for this configuration.
8 Defines a custom pre-processor, used to display a custom pre-process page where the user has the possibility to affect the package content.
9 The handler is responsible for defining the content of the package. See this chapter for information how to create a Handler.

2.4. Access

2.4.1. User Based Access Control

It is possible to grant access for a specific user by adding the user name to a list of user names. All users added to this list will have access to the configuration, no matter if they are or aren’t assigned to any roles or groups defined in the role list and group list respectively (See Role Based Access Control and Group Based Access Control).

Users are granted access by enclosing their user name within a User element. The User element is then added to the UserList element, which is a child of the Access element:

<Configuration id="cfg1">
    <!-- More configuration data here... -->
    <Access>
        <UserList>
            <User>person_TestEverything</User>
            <User>Test ManufacturingEngineer</User>
        </UserList>
    </Access>
    <!-- More configuration data here... -->
</Configuration>

2.4.2. Role Based Access Control

When controlling access based on roles it is important to know that all users that are assigned to that role, and all its child roles, will have access to the configuration.

Grant access for all users assigned to a specific role by enclosing the role name within a Role element. The Role element is then added to the RoleList element, which is a child of the Access element:

<Configuration id="cfg1">
    <!-- More configuration data here... -->
    <Access>
        <RoleList>
            <Role>role_GlobalUser</Role>
        </RoleList>
    </Access>
    <!-- More configuration data here... -->
</Configuration>

2.4.3. Group Based Access Control

When controlling access to a configuration based on groups, it is important to know that all users that are assigned to that group, or its child groups, will have access to the configuration.

Grant access for all users assigned to a specific group by enclosing the group name within a Group element. The Group element is then added to the GroupList element, which is a child of the Access element:

<Configuration id="cfg1">
    <!-- More configuration data here... -->
    <Access>
        <GroupList>
            <Group>Company Name</Group>
        </GroupList>
    </Access>
    <!-- More configuration data here... -->
</Configuration>

2.4.4. Combining Access Control

Note that when combining different types of access control, all users that are either explicitly added to the UserList element, OR are assigned to any of the roles added to the RoleList element, OR are assigned to any of the groups added to the GroupList element, will have access

2.5. Defining Valid Root Object Types

When setting up a configuration it is possible to define for which object type (or types) a configuration should be available.

Define valid root object type by enclosing the name of the type within a Type element. The Type element is added to the TypeList element, which is added to the ValidFor element. It is possible to add more than one valid root object type by adding another Type element to the TypeList element. If no valid root object type(s) has been defined, the configuration is considered to be valid for all object types.

<Configuration id="cfg1">
    <!-- More configuration data here... -->
    <ValidFor>
        <TypeList>
            <Type>type_Part</Type>
        </TypeList>
    </ValidFor>
    <!-- More configuration data here... -->
</Configuration>

2.6. Creating a Handler

A handler is a plain Java class, which implements an interface named com.technia.tvc.office.server.fpd.Handler.

The only method, which your handler needs to implement, has the following signature:

void perform(HandlerCtx ctx) throws TVCException;

For example, a handler without any logic would look like:

package mypackage;

import com.technia.tvc.office.server.fpd.Handler;
import com.technia.tvc.office.server.fpd.HandlerCtx;

public class MyHandler implements Handler {

    public void perform(HandlerCtx ctx) throws TVCException {
        // logic goes here...
    }
}

Within the perform method, you define what the package will contain. Everything added to the package is defined as being either a PackageEntry or a PackageDependency.

The difference between a PackageEntry and a PackageDependency is that while an Entry is a part of the Package, a Dependency is something that is downloaded after the package has been created but before the package is opened.

Currently the only dependency you can have is to a file checked-in to a business object in Matrix. The file might then be downloaded through the server, if is enabled in your environment. The benefit of not letting checked-in files being a part of the package, but being a dependency, is because of utilizing the benefits with the architecture (i.e. reducing the need of transferring large amount of data over WAN).

Generally, one should reduce the size of the dynamic package if possible – because the package it self is always downloaded from the Main Collaboration Server (), while dependencies can be downloaded from File Collaboration Servers ().

2.6.1. Writing the Perform Method

As mentioned before, the perform method does the work and defines the package content. The argument to the perform method, is an instance of a class named "HandlerCtx". The HandlerCtx class provides a large set of different functions that is used to add content to the package. See the specification below:

public interface HandlerCtx {
    /**
     * Returns the {@link UserData} containing relevant information
     * for the handler
     */
    UserData getUserData();

    /**
     * Adds an arbitrary {@link InputStream} to the package.
     *
     * @param in The input stream, which the data is read from
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry add(InputStream in);

    /**
     * Adds an arbitrary {@link Reader} to the package.
     *
     * @param in The reader, which the data is read from
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry add(Reader reader);

    /**
     * Adds a DOM document
     * @param doc
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addXML(Document doc);

    /**
     * Adds an arbitrary {@link InputSource} to the package.
     *
     * @param in The input source, which the XML data is read from
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addXML(InputSource in);

    /**
     * Adds an arbitrary {@link Source} representing XML data,
     * which is converted via the provided {@link Source xslt source}
     * to the package.
     *
     * @param in The XML source
     * @param xslt The XSLT source.
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addTransformXML(Source in, Source xslt);


    /**
     * Adds an arbitrary {@link Source} representing XML data,
     * which is converted via the provided {@link Source xslt source}
     * to the package using the XSLT parameters from the Map.
     *
     * @param in The XML source
     * @param xslt The XSLT source.
     * @param parameters The parameter map
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addTransformXML(Source document, Source xslt, Map parameters);

    /**
     * Adds the content of a page object as resource
     *
     * @param pageName The name of the page object to include in the package.
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addPageContent(String pageName);

    /**
     * Adds the result of a export businessobject output
     *
     * @param typePattern The type pattern
     * @param namePattern The name pattern
     * @param revPattern The revision pattern
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addExportBus(String typePattern,
                              String namePattern,
                              String revPattern);

    /**
     * Adds the result of a export businessobject output transformed via
     * the provided XSLT stylesheet.
     *
     * @param typePattern The type pattern
     * @param namePattern The name pattern
     * @param revPattern The revision pattern
     * @param xslt The stylesheet
     * @param parameters A map containing parameters (optional)
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addExportBus(String typePattern,
                              String namePattern,
                              String revPattern,
                              Source xslt,
                              Map parameters);



    /**
     * Adds the result of a export business object output transformed
     * via the provided XSLT stylesheet.
     *
     * @param typePattern
     * @param namePattern
     * @param revPattern
     * @param files
     * @param captured
     * @param icons
     * @param history
     * @param fromRelationships
     * @param toRelationships
     * @param states
     * @param archive
     * @param xslt
     * @param parameters
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addExportBus(String typePattern,
                              String namePattern,
                              String revPattern,
                              boolean files,
                              boolean captured,
                              boolean icons,
                              boolean history,
                              boolean fromRelationships,
                              boolean toRelationships,
                              boolean states,
                              boolean archive,
                              Source xslt,
                              Map parameters);

    /**
     * Adds the output from a JPO execution.
     *
     * @param jpo
     * @param function
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addJPO(String jpo,
                        String function);

    /**
     * Adds the output from a JPO execution. The provided
     * argument is passed to the JPO.
     *
     * @param jpo The name of the JPO to invoke
     * @param function The name of the method to invoke.
     * @param argument An argument.
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addJPO(String jpo,
                        String function,
                        Serializable argument);



    /**
     * Adds the output from a MQL command execution.
     *
     * @param mqlCommand The command to execute
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addMQL(String mqlCommand);

    /**
     * Adds a file from a businessobject to the package.
     *
     * @param type The type
     * @param name The name
     * @param revision The revision
     * @param format The format
     * @param fileName The name of the file
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addFile(String type,
                         String name,
                         String revision,
                         String format,
                         String fileName);

    /**
     * Adds a file from a businessobject to the package.
     *
     * @param objectId The id of the object
     * @param format The format
     * @param fileName The name of the file
     * @return A {@link PackageEntry entry} used for defining properties
     * on the entry.
     */
    PackageEntry addFile(String objectId,
                         String format,
                         String fileName);


	/**
     * Adds a path till the leaf node of the package if there is no file checked in
     *
     * @param path
     * @return
     */
    void addEmptyPackageName(String path);

    /**
     * Adds the output from a structure expansion
     *
     * @param rootObjectId The id of the object to expand
     * @param roleName The name of the role, which the filters are stored on.
     * @param filterNames The names of the filters to use.
     * @param expandLevels The number of levels to expand
     * @param tableName The name of the table to apply on the result
     * @return A {@link TableExportEntry}
     */
    TableExportEntry addExpandedData(String rootObjectId,
                                     String roleName,
                                     String[] filterNames,
                                     int expandLevels,
                                     String tableName);


    /**
     * Adds the objects returned by the specified inquiry, evaluated with
     * the specified table.
     *
     * @param inquiryName The name of the inquiry to invoke
     * @param args The inquiry arguments
     * @param tableName The name of the table to apply on the result
     * @return A {@link TableExportEntry}
     */
    TableExportEntry addTableData(String inquiryName,
                                  Map args,
                                  String tableName);

    /**
     * Adds the objects returned by the specified JPO, evaluated with
     * the specified table.
     *
     * @param jpoName The name of the JPO to invoke
     * @param function The name of the function to invoke.
     * @param args The JPO arguments
     * @param tableName The name of the table to apply on the result
     * @return A {@link TableExportEntry}
     */
    TableExportEntry addTableData(String jpoName,
                                  String function,
                                  Map args,
                                  String tableName);
    /**
     * Adds the objects returned by the query arguments, evaluated with
     * the specified table.
     *
     * @param typePattern The type pattern
     * @param namePattern The name pattern
     * @param revPattern The revision pattern
     * @param ownerPattern The owner pattern
     * @param vaultPattern The vault pattern
     * @param whereClause The where clause
     * @param limit The query limit
     * @param expandType True if to include sub types to the specified type pattern
     * @param tableName The name of the table to apply on the result
     * @return A {@link TableExportEntry}
     */
    TableExportEntry addTableData(String typePattern,
                                  String namePattern,
                                  String revPattern,
                                  String ownerPattern,
                                  String vaultPattern,
                                  String whereClause,
                                  int limit,
                                  boolean expandType,
                                  String tableName);

    /**
     * Adds a custom table bean to the package.
     *
     * @param table The tablebean to add.
     * @return A {@link TableExportEntry}
     */
    TableExportEntry addTable(TableBean table);


    /**
     * Adds a {@link FileDependency file dependency}
     *
     * @param type
     * @param name
     * @param revision
     * @param format
     * @param fileName
     * @return
     */
    PackageDependency addFileDependency(String type,
                                        String name,
                                        String revision,
                                        String format,
                                        String fileName);
    /**
     * Adds a {@link FileDependency file dependency}
     *
     * @param objectId The id of the object
     * @param format The format
     * @param fileName The name of the file
     * @return A {@link PackageDependency}
     */
    PackageDependency addFileDependency(String objectId,
                                        String format,
                                        String fileName);

    /**
     * Removes a previously added dependency.
     *
     * @param dep
     * @return True if the dependency was removed
     */
    boolean removeDependency(PackageDependency dep);
}

Many of the methods above returns either an instance of "PackageEntry", "TableExportEntry" or "PackageDependency", for each of these return values, you have some common functions that operate on the returned object:

    /**
     * Defines the name of the file, which the content is stored in.
     */
    void setSaveAs(String name);

    /**
     * Defines the directory, where the file is stored.
     */
    void setSaveIn(String dir);

    /**
     * Defines if the file should be opened once the package is created.
     * NOTE: Only one file might be opened after the package has been created
     */
    void setOpen();

Additionally, the "TableExportEntry" instance has the following methods:

/**
 * Defines if the output should be XML
 */
void setXMLOutput();

/**
 * Defines if the output should be
 */
void setCSVOutput();

Additionally, the "PackageDependency" instance has the following methods:

/**
 * Returns true if the dependency is valid. I.e. if the file
 * really can be downloaded. This can be used to perform some
 * logic, when the file for some reason is unreachable.
 */
boolean isValid();

/**
 * Set to true if the dependency is a ZIP archive, and if
 * it is supposed to be automatically un-compressed.
 */
void setExtractIfZIP(boolean b);

2.7. Creating a Configurable Handler

Instead of defining a custom handler, you have the possibility to use a so called configurable handler, which doesn’t require you to do any Java coding. A configurable handler supports a subset of the possibilities, which can be done through implementing a Java based handler.

An example on how to define a configurable handler is provided below:

<Handler>
    <!-- Execute some MQL commands -->
    <MQL saveAs="parts.txt">temp query bus Part * * select id dump |</MQL>
    <MQL saveAs="structure.txt">expand businessobject ${OBJECTID} from recurse to all select bus id select rel id dump |;</MQL>

    <!-- Execute a JPO -->
    <JPO program="MyJPO" method="createXML" saveAs="data.xml"/>

    <!-- Checkout a file -->
    <File open="true">
        <Type>Document Template</Type>
        <Name>-0001</Name>
        <Revision>A</Revision>
        <FileName>Template.xls</FileName>
        <Format>generic</Format>
    </File>

    <!-- Expand a structure, using the filters from the specified role -->
    <!-- then evaluate the structure using the system-table and export -->
    <!-- the data in XML format -->
    <StructureData format="xml"
                   table="My Table"
                   filters="EBOM From,Specifications"
                   role="Global User"
                   expandTo="1"
                   saveAs="structure.xml"/>

    <!-- Load a table from the specified inquiry -->
    <!-- then evaluate the system-table over these objects and export -->
    <!-- the data in CSV format -->
    <TableData format="csv"
               table="My Table"
               inquiry="My Inquiry"
               saveAs="tabledata.xml"/>
</Handler>

The supported instructions, which can be configured through the XML format is:

  1. MQL – Adds output from an arbitrary MQL command.

  2. JPO – Adds the result from a JPO method invocation

  3. File – Adds a file to be checked-out from Matrix

  4. StructureData – Expands a structure, and adds the data either CSV or XML formatted.

  5. TableData – Similar to StructureData, but for list of objects.

  6. URL – Content of a URL

These instructions are described more in detail in the sub-chapters below.

When using a configurable handler, you should not specify any className attribute on the "Handler" element.

2.7.1. General

All the instructions support the following attributes:

Attribute Name Description Example Required

saveIn

Defines the name/path where the file is saved in. Default is in the root of the package.

/data/files

Yes

saveAs

Defines the name of the file to which the data is written into

Data.xml

No

open

Defines if the file should be opened after the package has been created. Note that only one file can be defined to be opened.

Default is FALSE.

True

No

addEmptyPackageName

If the folder is empty (no entries) and we want to show the path of folder structure; then we can achieve it by passing name/path as an argument. Default path is the root of the package.

/root/folder

No

2.7.2. MQL

Executes the command and the output from the command is stored in the specified file.

Additional attributes supported by this instruction:

Attribute Name Description Example Required

parseMacros

Whether or not if the MQL command should be parsed.

False (default is true)

No

execForEach

Whether or not if the MQL command should be executed for each of the objects provided as input for the file package creation.

If set to true, parseMacros is assumed even if this flag has been set to false.

When this attribute has been set to true, and there were more than one object as input, the OBJECTID and OBJECTTYPE macros are substituted for each execution of the command.

Also, the output from the command is saved into different files. For example, if saveAs is mql.txt, it will be mql_0.txt, mql_1.txt, …, mql_10.txt etc.

Or, if no suffix is specified, mql_0, mql_1, …, mql_10 etc.

True (default is false)

No

When the parseMacros attribute is true, the MQL command can contain macros that are parsed. The following macros can be used:

  • ${OBJECTID} – Substitutes the macro with the object id (if several object’s were provided as input, the first object id is used)

  • ${OBJECTIDS} – Substitutes the macro with a pipe separated list of all object-ids for all objects provided as input.

  • ${OBJECTTYPE} – Substitutes the macro with the object type (if several object’s were provided as input, the first object-type is used)

  • ${OBJECTTYPES} - Substitutes the macro with a pipe separated list of all object-types for all objects provided as input.

  • ${USER} – Substitutes the value to the name of the current user.

Example:

<Handler>
    <MQL execForEach="true" saveAs="mql.txt">
        expand bus $\{OBJECTID} from recurse to 1 select bus id type name dump |
    </MQL>
</Handler>

2.7.3. URL

This instruction can be used to include the content of an URL into the package.

The URL is assumed to be relative to the application context-root if it doesn’t start with http: or https:.

<Handler>
    <URL saveIn="images"
         saveAs="technia-logo.gif">http://www.technia.com/images/logo.gif</URL>
    <URL saveIn="images"
         saveAs="Part.gif">/common/images/type_Part.gif</URL>
</Handler>

2.7.4. JPO

Executes a method in a JPO, and stores the output in the specified file. The JPO must return some value.

Additional attributes supported by this instruction:

Attribute Name Description Example Required

program

Defines the name of the JPO program

My Program

yes

method

Defines the method to be invoked

myMethod

Yes

It is also possible to provide additional arguments to the JPO, see the example below:

<Handler>
    <JPO program="MyJPO" method="createXML" saveAs="data.xml">
        <Arg name="first-arg" value="value of arg 1"/>
        <Arg name="second-arg" value="value of arg 2"/>
    </JPO>
</Handler>

When the JPO is invoked, and the string array is unpacked using JPO.unpackArgs, you will get a Map with following key/values:

Name Type Content Description

requestMap

java.util.Map

The map contains String keys and String[] values.

Contains the request parameters used when invoking the FPD

objectList

java.util.List

A list of "java.util.Map" instances.

Each map contains string keys and string values.

If the FPD were invoked around an object, this information contains the id+type information from these object(s).

arguments

java.util.Map

The map contains String keys and String values.

The optional arguments as configured through the XML configuration.

2.7.5. File

The File instruction is used to download a file that is checked in to a business object in Matrix.

The example below illustrates how to use this instruction.

<Handler>
    <File open="true">
        <Type>Document Template</Type>
        <Name>-0001</Name>
        <Revision>A</Revision>
        <FileName>Template.xls</FileName>
        <Format>generic</Format>
    </File>
</Handler>

Additional attributes supported by the File element are

Attribute Name Description Example Required

extractIfZIP

If the downloaded file is a ZIP archive, this flag can be used to automatically unzip the file once it has been downloaded.

True (default is FALSE)

No

2.7.6. TableData

The TableData instruction can be used to evaluate a table over a list of objects, and include the data, either in CSV (comma separated) or in XML format, in the package.

The list of objects can either be retrieved through evaluating an inquiry or by executing a JPO.

Below are some examples that illustrate how to use this instruction:

<Handler>
    <TableData format="csv"
               table="My Table"
               inquiry="My Inquiry"
               saveAs="table1.xml"/>
</Handler>
<Handler>
    <TableData format="xml"
               table="My Table"
               jpo="MyJPO"
               method="myMethod"
               saveAs="table2.xml"/>
</Handler>

Also, it is possible to provide arguments to either the inquiry or to the JPO method:

<Handler>
    <TableData format="csv" table="My Table" ... saveAs="table1.xml">
        <Arg name="arg1" value="value1"/>
        <Arg name="arg2" value="value2"/>
    </TableData>
</Handler>
You can create complex cell data, by creating a DataHandler within the table that produces XML output.

2.7.7. StructureData

The StructureData instruction is similar to the TableData instruction, but it can be used to extract a structure in either CSV or XML format.

The structure is expanded according to filters that are stored inside the workspace of a role.

Below is an example how to use this element:

<Handler>
    <StructureData format="xml"
        table="My Table"
        filters="EBOM From,Specifications"
        role="Global User"
        expandTo="1"
        saveAs="structure.xml"/>
</Handler>

The filters are created through MQL, and must be created for the role as specified. An example MQL command to create a filter from MQL is shown below:

set context user creator pass xxx;
set workspace user "Global User";
add filter "EBOM From" appliesto relationship from type EBOM;
add filter "Specifications" appliesto relationship from type "Part Specification";

2.8. Integration with Personal Browser

The file package functionality can be used together with the TVC Personal Browser component, if that is available. The benefits by using the file package functionality within the TVC office integration to create a personal browser are:

  1. Attached business object files are checked out through the FCS server

  2. The generated Personal Browser package is automatically uncompressed, and the personal browser is automatically shown after download is completed. I.e. the user does not need to use a third party tool to do the decompression nor s/he does not have to browse for the personal browser files in the file explorer in order to open it up.

To configure the file package functionality to use a personal browser configuration, you will need to create a configuration like the example below:

<Configuration id="pbEbomWithFilesConfig">
    <DisplayName>EBOM File Package</DisplayName>
    <Description>Creates a package with all the drawings from the EBOM structure</Description>
    <PackageName>
        <Text>PersonalBrowser</Text>
        <Text>_</Text>
        <Basic>type</Basic>
        <Text>_</Text>
        <Basic>name</Basic>
        <Text>_</Text>
        <Basic>revision</Basic>
    </PackageName>
    <ValidFor>
        <TypeList>
            <Type>type_Part</Type>
        </TypeList>
    </ValidFor>
    <RowSelectType>single</RowSelectType>
    <Handler className="com.technia.tvc.personalbrowser.handler.classic.oifpd.FPDHandler"> (1)
        <Property name="personalBrowserConfigName" value="defPartConf"/>
    </Handler>
</Configuration>
1 Define the special handler and the configuration to be used , and the property within this element are used to specify what personal browser configuration to be used.

When the file package download functionality is used to create a personal browser, some features such as FTP transfer of the package can not be used.