Functions and Models
Function name | Methods | Return type | Description |
---|---|---|---|
AthleteFunction | toAthlete(INode node) | com.subshell.sophora.sport.model.athlete.Athlete | Converts the given INode to a Java model of type Athlete . |
DataTableFunction | toDataTable(INode node) | com.subshell.sophora.sport.model.datatable.DataTable | Converts the given INode to a Java model of type DataTable . |
MatchRoundFunction | toMatchRound(INode node) | com.subshell.sophora.sport.model.round.MatchRound | Converts the given INode to a Java model of type MatchRound . |
getMatchRounds() | List<com.subshell.sophora.sport.model.round.MatchRound> | Finds all match round documents and returns a Java model of type MatchRound for each of them as a list. | |
ShorthandFunction | toShorthand(INode node) | com.subshell.sophora.sport.model.shorthand.Shorthand | Converts the given INode to a Java model of type Shorthand . |
SportMenuFunction | toSportMenu(INode node) | com.subshell.sophora.sport.model.menu.SportMenu | Converts the given INode to a Java model of type SportMenu . |
List<SportMenu> getSportMenus() | List<com.subshell.sophora.sport.model.menu.SportMenu> | Finds all match round documents and returns a Java model of type SportMenu for each of them as a list. | |
TeamFunction | toTeam(INode node) | com.subshell.sophora.sport.model.team.Team | Converts the given INode to a Java model of type Team . |
A full list of all available Java models (including those mentioned in the functions table above) can be found in the Javadoc of the TableStar Model which can be downloaded from software.subshell.com.
Integration
To integrate the TableStar Delivery Model into your delivery you need to do the following steps:
- Define a maven dependency to the TableStar Delivery Model release you want to use, i.e.
<dependency>
<groupId>com.subshell.sophora.sport</groupId>
<artifactId>tablestar-delivery-model</artifactId>
<version>5.0.0</version>
</dependency>
- Append the following to your
sophora.delivery.function.packageNames
in yoursophora.properties
to be able to use the functions mentioned above:
sophora.delivery.function.packageNames=com.subshell.sophora.sport.deliverymodel.function
- Append the following to your
sophora.delivery.model.packageNames
in yoursophora.properties
to be able to use the models mentioned above:
sophora.delivery.model.packageNames=com.subshell.sophora.sport.deliverymodel.model
In order to be able to initialize the Spring beans of the TableStar Delivery Model you will also need to add the following parts:
- Add the following Java class to your src folder:
package webapp.sport.context;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import com.subshell.sophora.delivery.api.DeliveryUtils;
/**
* Initializes the application context of the delivery.
*/
@Component
public class ContextBridge {
@Autowired
private ApplicationContext appContext;
@PostConstruct
private void setContext() {
DeliveryUtils.setRootApplicationContext(appContext);
}
}
- In your WEB-INF folder add a new file called
tablestar-context.xml
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:annotation-config />
<!-- the first package 'webapp.sport.context' must match the package of your ContextBridge class -->
<context:component-scan base-package="webapp.sport.context,com.subshell.sophora.sport" />
<context:property-placeholder location="/WEB-INF/sites/sophora.properties" />
</beans>
- Add the
tablestar-context.xml
to your WEB-INF/web.xml:
[...]
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/tablestar-context.xml</param-value>
</context-param>
[...]
- If not already done, add the
ContextLoaderListener
(after the existingSophoraInitializer
) to your WEB-INF/web.xml:
[...]
<listener>
<listener-class>com.subshell.sophora.delivery.configuration.SophoraInitializer</listener-class>
</listener>
[...]
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
[...]
Example-JSPs
You can find several examples on how to work with the TableStar Delivery Model, in order to access the Java models, in the TableStar Demosite. The Demosite can be downloaded from software.subshell.com.
- already imported the TableStar configuration files
- have some example documents (e.g. match round documents if you want to test the
matchRound.jsp
)