Search in sources :

Example 1 with ParseException

use of org.activityinfo.legacy.shared.exception.ParseException in project activityinfo by bedatadriven.

the class CreateReportHandler method execute.

@Override
public CommandResult execute(CreateReport cmd, User user) {
    // verify that the XML is valid
    try {
        ReportDefinition reportDef = new ReportDefinition();
        String xml = ReportParserJaxb.createXML(cmd.getReport());
        reportDef.setXml(xml);
        if (cmd.getDatabaseId() != null) {
            reportDef.setDatabase(em.getReference(Database.class, cmd.getDatabaseId()));
        }
        reportDef.setTitle(cmd.getReport().getTitle());
        reportDef.setDescription(cmd.getReport().getDescription());
        reportDef.setOwner(user);
        reportDef.setVisibility(1);
        em.persist(reportDef);
        return new CreateResult(reportDef.getId());
    } catch (JAXBException e) {
        throw new ParseException(e.getMessage());
    }
}
Also used : CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) JAXBException(javax.xml.bind.JAXBException) Database(org.activityinfo.server.database.hibernate.entity.Database) ParseException(org.activityinfo.legacy.shared.exception.ParseException) ReportDefinition(org.activityinfo.server.database.hibernate.entity.ReportDefinition)

Aggregations

JAXBException (javax.xml.bind.JAXBException)1 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)1 ParseException (org.activityinfo.legacy.shared.exception.ParseException)1 Database (org.activityinfo.server.database.hibernate.entity.Database)1 ReportDefinition (org.activityinfo.server.database.hibernate.entity.ReportDefinition)1