Package it.eng.spagobi.analiticalmodel.document.dao

Examples of it.eng.spagobi.analiticalmodel.document.dao.IViewpointDAO


        String driverClassName = obj.getEngine().getDriverName();
        IEngineDriver aEngineDriver = (IEngineDriver)Class.forName(driverClassName).newInstance();
        Map mapPars = aEngineDriver.getParameterMap(obj, profile, executionRole);
        String id = (String) requestSB.getAttribute("vpId");
        if (id != null){
          IViewpointDAO VPDAO = DAOFactory.getViewpointDAO();   
          Viewpoint vp =  VPDAO.loadViewpointByID(new Integer(id));
          String[] vpParameters = vp.getVpValueParams().split("%26");
          if (vpParameters != null){
            for (int i=0; i< vpParameters.length; i++){
              String param = (String)vpParameters[i];
              String name = param.substring(0, param.indexOf("%3D"));
View Full Code Here


   */
  private List getViewpointList(BIObject obj) {
    logger.debug("IN");
    List viewpoints = new ArrayList();
    try {
      IViewpointDAO biVPDAO = DAOFactory.getViewpointDAO();
      IEngUserProfile profile = getUserProfile();
      viewpoints = biVPDAO.loadAccessibleViewpointsByObjId(obj.getId(), profile);
    } catch (Exception e) {
      logger.error("Error retriving the viewpoint list", e);
    } finally {
      logger.debug("OUT");
    }
View Full Code Here

    }
    if (contentVP != null && contentVP.endsWith("%26")) {
      contentVP = contentVP.substring(0, contentVP.length() - 3);
    }

    IViewpointDAO biViewpointDAO = DAOFactory.getViewpointDAO();
    biViewpointDAO.setUserProfile(profile);
    // check if a viewpoint with the same name yet exists
    Viewpoint tmpVP = biViewpointDAO.loadViewpointByNameAndBIObjectId(nameVP, obj.getId());
    if (tmpVP != null) {
      errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
          6002, null));
      // set into the response the right information for loopback
      response.setAttribute(SpagoBIConstants.PUBLISHER_NAME,
      "ExecuteBIObjectPageParameter");
      logger.debug("OUT");
      return;
    }
    Viewpoint aViewpoint = new Viewpoint();
    aViewpoint.setBiobjId(obj.getId());
    aViewpoint.setVpName(nameVP);
    aViewpoint.setVpOwner(ownerVP);
    aViewpoint.setVpDesc(descVP);
    aViewpoint.setVpScope(scopeVP);
    aViewpoint.setVpValueParams(contentVP);
    aViewpoint.setVpCreationDate(new Timestamp(System.currentTimeMillis()));
    biViewpointDAO.insertViewpoint(aViewpoint);

    // set data in response
    response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "ExecuteBIObjectPageParameter");

    logger.debug("OUT");
View Full Code Here

  private void eraseViewpoint(SourceBean request, SourceBean response)
  throws EMFUserError, SourceBeanException, EMFInternalError {
    logger.debug("IN");
    UserProfile profile = (UserProfile) getUserProfile();
    String userId = profile.getUserId().toString();
    IViewpointDAO vpDAO = DAOFactory.getViewpointDAO();
    List viewpointsIdsList = request.getAttributeAsList("vpId");
    if (viewpointsIdsList != null && !viewpointsIdsList.isEmpty()) {
      Iterator it = viewpointsIdsList.iterator();
      while (it.hasNext()) {
        String vpIdStr = (String) it.next();
        Integer vpId = new Integer(vpIdStr);
        // check if the user is able to erase the viewpoint
        boolean canDelete = false;
        // if user is administrator, he can delete it
        if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
          canDelete = true;
        } else {
          // if user is not administrator, he can delete it only if he is the owner
          Viewpoint vp = vpDAO.loadViewpointByID(vpId);
          if (vp == null) {
            logger.warn("Viewpoiny with id = " + vpId + " not found!");
            continue;
          }
          if (vp.getVpOwner().equals(userId)) {
            canDelete = true;
          }
        }
        if (canDelete) {
          logger.error("Deleting viewpoint with id = " + vpId + " ...");
          vpDAO.eraseViewpoint(vpId);
        } else {
          logger.error("User cannot delete selected viewpoint!! UserId = [" + userId + "]; viepoint id =[" + vpId + "]");
        }
      }
    }
View Full Code Here

  private void viewViewpoint(SourceBean request, SourceBean response)
  throws Exception {
    logger.debug("OUT");
    String id = (String) request.getAttribute("vpId");

    IViewpointDAO VPDAO = DAOFactory.getViewpointDAO();
    Viewpoint vp = VPDAO.loadViewpointByID(new Integer(id));
    ExecutionInstance instance = getExecutionInstance();
    BIObject obj = instance.getBIObject();
    // gets parameter's values and creates a string of values
    List parameters = obj.getBiObjectParameters();
    Iterator iterParams = parameters.iterator();
View Full Code Here

    String viewpointScope;
    String viewpointOwner;
    JSONObject viewpointJSON;
    String viewpointString;
   
    IViewpointDAO viewpointDAO;
    Viewpoint viewpoint;

   
   
   
    logger.debug("IN");
   
    try{
     
      viewpointName = getAttributeAsString(NAME);
      viewpointDescription = getAttributeAsString(DESCRIPTION);
      viewpointScope = getAttributeAsString(SCOPE);
      viewpointJSON = getAttributeAsJSONObject( VIEWPOINT );
     
      logger.debug("Parameter [" + NAME + "] is equals to [" + viewpointName + "]");
      logger.debug("Parameter [" + DESCRIPTION + "] is equals to [" + viewpointDescription + "]");
      logger.debug("Parameter [" + SCOPE + "] is equals to [" + viewpointScope + "]");
      logger.debug("Parameter [" + viewpointScope + "] is equals to [" + viewpointJSON + "]");
     
      Assert.assertTrue(!StringUtilities.isEmpty(viewpointScope), "Viewpoint's name cannot be null or empty");
      Assert.assertNotNull(!StringUtilities.isEmpty(viewpointDescription), "Viewpoint's description cannot be null or empty");
      Assert.assertNotNull(!StringUtilities.isEmpty(viewpointScope), "Viewpoint's scope cannot be null or empty");
      Assert.assertNotNull(viewpointJSON, "Viewpoint's content cannot be null");
     
      executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      Assert.assertNotNull(executionInstance, "Execution instance cannot be null");
     
      userProfile = this.getUserProfile();
      Assert.assertNotNull(userProfile, "Impossible to retrive user profile");
     
      biobjectId = executionInstance.getBIObject().getId();
      Assert.assertNotNull(executionInstance, "Impossible to retrive analytical document id");
     
      logger.debug("User: [" + userProfile.getUserUniqueIdentifier() + "]");
      logger.debug("Document Id:  [" + biobjectId + "]");
     
      viewpointOwner = (String) ((UserProfile)userProfile).getUserId();
     
      Iterator it = viewpointJSON.keys();
      Assert.assertTrue(it.hasNext(), "Viewpoint's content cannot be empty");
      viewpointString = "";
      while (it.hasNext()) {
        String parameterName = (String) it.next();
        String parameterValue;
        try {
          parameterValue = viewpointJSON.getString( parameterName );
        } catch (JSONException e) {
          logger.error("Impossible read value for the parameter [" + parameterName + "] into viewpoint's content", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Impossible read value for the parameter [" + parameterName + "] into viewpoint's content", e);
        }
       
        // defines the string of parameters to save into db
        if(!StringUtilities.isEmpty(parameterValue)) {
          viewpointString += parameterName + "%3D" + parameterValue + "%26";
        }
      }
     
      if (viewpointString.endsWith("%26")) {
        viewpointString = viewpointString.substring(0, viewpointString.length() - 3);
      }
     
      logger.debug("Viewpoint's content will be saved on database as: [" + viewpointString + "]");
     
      try {
        viewpointDAO = DAOFactory.getViewpointDAO();
        viewpoint = viewpointDAO.loadViewpointByNameAndBIObjectId(viewpointName, biobjectId);
        if (viewpoint != null) throw new SpagoBIServiceException(SERVICE_NAME, "A viewpoint with the name [" + viewpointName + "] alredy exist");
        //Assert.assertTrue(viewpoint == null, "A viewpoint with the name [" + viewpointName + "] alredy exist");
      } catch (EMFUserError e) {
        logger.error("Impossible to check if a viewpoint with name [" + viewpointName + "] already exists", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to check if a viewpoint with name [" + viewpointName + "] already exists", e);
     
     
      try {
        viewpointDAO = DAOFactory.getViewpointDAO();
        viewpointDAO.setUserProfile(userProfile);
        viewpoint = new Viewpoint();
        viewpoint.setBiobjId( biobjectId );
        viewpoint.setVpName( viewpointName );
        viewpoint.setVpOwner( viewpointOwner );
        viewpoint.setVpDesc( viewpointDescription );
        viewpoint.setVpScope( viewpointScope );
        viewpoint.setVpValueParams( viewpointString );
        viewpoint.setVpCreationDate(new Timestamp(System.currentTimeMillis()));
        viewpointDAO.insertViewpoint(viewpoint);
      } catch (EMFUserError e) {
        logger.error("Impossible to save viewpoint [" + viewpointName + "]", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to check if a viewpoint with name [" + viewpointName + "] already exists", e);
      }
       
View Full Code Here

   
    List viewpoints;
    ExecutionInstance executionInstance;
    IEngUserProfile userProfile;
    Integer biobjectId;
    IViewpointDAO viewpointDAO;
   
   
   
    logger.debug("IN");
   
    try{
      executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      Assert.assertNotNull(executionInstance, "Execution instance cannot be null");
     
      userProfile = this.getUserProfile();
      Assert.assertNotNull(userProfile, "Impossible to retrive user profile");
     
      biobjectId = executionInstance.getBIObject().getId();
      Assert.assertNotNull(executionInstance, "Impossible to retrive analytical document id");
     
      logger.debug("User: [" + userProfile.getUserUniqueIdentifier() + "]");
      logger.debug("Document Id:  [" + biobjectId + "]");
     
      try {
        viewpointDAO = DAOFactory.getViewpointDAO();
        viewpoints = viewpointDAO.loadAccessibleViewpointsByObjId(biobjectId, getUserProfile());
      } catch (EMFUserError e) {
        logger.error("Cannot load viewpoints for document [" + biobjectId + "]", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot load viewpoints for document [" + biobjectId + "]", e);
      }
         
View Full Code Here

    Integer biobjectId;
   
    String viewpointIds;
    String[] ids;
   
    IViewpointDAO viewpointDAO;
    Viewpoint viewpoint;
   
    logger.debug("IN");
   
    try {
     
      viewpointIds = this.getAttributeAsString(VIEWPOINT_IDS);
     
      logger.debug("Parameter [" + VIEWPOINT_IDS + "] is equals to [" + viewpointIds + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty(viewpointIds), "Viewpoint's ids cannot be null or empty");
     
      ids = viewpointIds.split(",");
     
      executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      Assert.assertNotNull(executionInstance, "Execution instance cannot be null");
     
      userProfile = this.getUserProfile();
      Assert.assertNotNull(userProfile, "Impossible to retrive user profile");
     
      biobjectId = executionInstance.getBIObject().getId();
      Assert.assertNotNull(executionInstance, "Impossible to retrive analytical document id");
     
      logger.debug("User: [" + userProfile.getUserUniqueIdentifier() + "]");
      logger.debug("Document Id:  [" + biobjectId + "]");
     
      /*
      Assert.assertTrue(userProfile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN),
          "User [" + userProfile.getUserUniqueIdentifier()+ "] have not the rights to delete viewpoints");
      */
      for(int i = 0; i < ids.length; i++) {
        try {
          viewpointDAO = DAOFactory.getViewpointDAO();
          viewpoint =  viewpointDAO.loadViewpointByNameAndBIObjectId( ids[i] , biobjectId);
          Assert.assertNotNull(viewpoint, "Viewpoint [" + ids[i] + "] does not exist on the database");
         
         
          viewpointDAO.eraseViewpoint( viewpoint.getVpId() );
          logger.error("Viewpoint [" + ids[i] + "] succesfully deleted");
         
        } catch (EMFUserError e) {
          logger.error("Impossible to delete viewpoint with name [" + ids[i] + "] already exists", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to delete viewpoint with name [" + ids[i] + "] already exists", e);
View Full Code Here

TOP

Related Classes of it.eng.spagobi.analiticalmodel.document.dao.IViewpointDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.