1 package com.jaspersoft.jasperserver.war.action; 2 3 import java.io.IOException ; 4 import java.net.URL ; 5 6 import javax.servlet.jsp.JspException ; 7 8 import org.springframework.webflow.Event; 9 import org.springframework.webflow.RequestContext; 10 import org.springframework.webflow.action.FormAction; 11 import org.xml.sax.SAXException ; 12 13 import com.jaspersoft.jasperserver.api.common.domain.impl.ExecutionContextImpl; 14 import com.jaspersoft.jasperserver.api.metadata.common.service.RepositoryService; 15 import com.jaspersoft.jasperserver.api.metadata.olap.domain.OlapUnit; 16 import com.jaspersoft.jasperserver.api.metadata.olap.service.OlapConnectionService; 17 import com.tonbeller.jpivot.mondrian.MondrianModel; 18 import com.tonbeller.jpivot.mondrian.MondrianModelFactory; 19 import com.tonbeller.jpivot.olap.model.OlapModel; 20 21 public class DisplayOlapModelAction extends FormAction 22 { 23 public static final String OLAPUNIT_ATTR = "olapUnit"; 24 25 28 private RequestContext requestContext; 29 30 private RepositoryService repository; 31 32 private OlapConnectionService olapConnection; 33 34 private String olapUnitName; 35 36 private OlapUnit olapUnit; 37 38 private OlapModel olapModel; 39 40 43 public RepositoryService getRepository() { 44 return repository; 45 } 46 47 public void setRepository(RepositoryService repository) { 48 this.repository = repository; 49 } 50 51 public OlapConnectionService getOlapConnection() { 52 return olapConnection; 53 } 54 55 public void setOlapConnection(OlapConnectionService olapConnection) { 56 this.olapConnection = olapConnection; 57 } 58 59 public OlapModel getOlapModel() { 60 return olapModel; 61 } 62 63 public void setOlapModel(OlapModel olapModel) { 64 this.olapModel = olapModel; 65 } 66 67 73 public Event getOlapUnit(RequestContext requestContext) 74 { 75 Event result = success(); 76 77 ExecutionContextImpl executionContext = new ExecutionContextImpl(); 78 79 this.requestContext = requestContext; 80 81 if ((olapUnitName = (String ) requestContext.getFlowScope().get(OLAPUNIT_ATTR)) == null) 82 { 83 result = error(); 84 } 85 else if ((olapUnit = (OlapUnit) repository.getResource(executionContext, olapUnitName)) == null) 86 { 87 result = error(); 88 } 89 90 return result; 91 } 92 93 99 public Event createOlapModel(RequestContext requestContext) 100 { 101 Event result = success(); 102 103 ExecutionContextImpl executionContext = new ExecutionContextImpl(); 104 105 olapModel = olapConnection.createOlapModel(executionContext, olapUnit); 106 107 if (olapModel == null) 108 { 109 result = error(); 110 } 111 112 return result; 113 } 114 115 public Event displayOlapModel(RequestContext requestContext) 116 { 117 Event result = success(); 118 119 requestContext.getRequestScope().put("olapUnitName", olapUnitName); 120 121 return result; 122 } 123 } 124 | Popular Tags |