Examples of IDossierPartsTempDAO


Examples of it.eng.spagobi.engines.dossier.dao.IDossierPartsTempDAO

          aBIObjectParameter.setId(aSbiObjPar.getObjParId());
          objParDAO.eraseBIObjectParameter(aBIObjectParameter, aSession);
        }

        // delete dossier temp parts eventually associated
        IDossierPartsTempDAO dptDAO = DAOFactory.getDossierPartsTempDAO();
        dptDAO.eraseDossierParts(obj.getId());
        // delete dossier presentations eventually associated
        IDossierPresentationsDAO dpDAO = DAOFactory.getDossierPresentationDAO();
        dpDAO.deletePresentations(obj.getId());

        // update subreports table
View Full Code Here

Examples of it.eng.spagobi.engines.dossier.dao.IDossierPartsTempDAO

        xComponent);
      XDrawPages drawPages = xDrawPageSup.getDrawPages();
      logger.debug("Draw pages found: " + drawPages);
      int numPages = drawPages.getCount();
      logger.debug("Draw pages number: " + numPages);
      IDossierPartsTempDAO dptDAO = DAOFactory.getDossierPartsTempDAO();
      for (int i = 0; i < numPages; i++) {
    logger.debug("Start examining page " + i);
    // get images corresponding to that part of the template
    int pageNum = i + 1;
    Map images = dptDAO.getImagesOfDossierPart(dossierId, pageNum, workflowProcessId);
    logger.debug("Images map retrieved: " + images);
    // get draw page
    Object pageObj = drawPages.getByIndex(i);
    XDrawPage xDrawPage = (XDrawPage) UnoRuntime.queryInterface(XDrawPage.class, pageObj);
    logger.debug("Draw page: " + xDrawPage);
    // get shapes of the page
    XShapes xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xDrawPage);
    logger.debug("Shapes found: " + xShapes);
    int numShapes = xShapes.getCount();
    logger.debug("Shapes number: " + numShapes);
    // prepare list for shapes to remove and to add
    List shapetoremove = new ArrayList();
    List shapetoadd = new ArrayList();
    Object oBitmapsObj = xServiceFactory.createInstance("com.sun.star.drawing.BitmapTable");
    XNameContainer oBitmaps = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oBitmapsObj);
    // check each shape
    for (int j = 0; j < numShapes; j++) {
        logger.debug("Start examining shape " + j + " of page " + i);
        Object shapeObj = xShapes.getByIndex(j);
        XShape xshape = (XShape) UnoRuntime.queryInterface(XShape.class, shapeObj);
        logger.debug("xshape: " + xshape);
        XText xShapeText = (XText) UnoRuntime.queryInterface(XText.class, shapeObj);
        logger.debug("XShapeText retrived " + xShapeText);
        if (xShapeText == null) {
      continue;
        }
        String shapeText = xShapeText.getString();
        logger.debug("shape text retrived " + shapeText);
        shapeText = shapeText.trim();
        // sobstitute the placeholder with the correspondent image
        if (shapeText.startsWith("spagobi_placeholder_")) {
      String nameImg = shapeText.substring(20);
      logger.debug("Name of the image corresponding to the placeholder: " + nameImg);
      Size size = xshape.getSize();
      Point position = xshape.getPosition();
      logger.debug("Stored shape size and position on local variables");
      shapetoremove.add(xshape);
      logger.debug("Shape loaded on shapes to be removed");
      Object newShapeObj = xServiceFactory.createInstance("com.sun.star.drawing.GraphicObjectShape");
      logger.debug("New shape object instantiated: " + newShapeObj);
      XShape xShapeNew = (XShape) UnoRuntime.queryInterface(XShape.class, newShapeObj);
      logger.debug("New XShape instantiated from the new shape object: " + xShapeNew);
      xShapeNew.setPosition(position);
      xShapeNew.setSize(size);
      logger.debug("Stored size and position set for the new XShape");
      // write the corresponding image into file system
      String pathTmpImgFolder = tempFolder + "/tmpImgs/";
      logger.debug("Path tmp images: " + pathTmpImgFolder);
      File fileTmpImgFolder = new File(pathTmpImgFolder);
      fileTmpImgFolder.mkdirs();
      logger.debug("Folder tmp images: " + pathTmpImgFolder + " created.");
      String pathTmpImg = pathTmpImgFolder + nameImg + ".jpg";
      logger.debug("Path tmp image file: " + pathTmpImg);
      File fileTmpImg = new File(pathTmpImg);
      FileOutputStream fos = new FileOutputStream(fileTmpImg);
      byte[] content = (byte[]) images.get(nameImg);
      if (content == null)
          logger.debug("Image with name \"" + nameImg + "\" was NOT found!!!");
      else
          logger.debug("Image with name \"" + nameImg + "\" was found");
      fos.write(content);
      fos.flush();
      fos.close();
      logger.debug("Tmp image file written");
      // load the image into document
      XPropertySet xSPS = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xShapeNew);
      try {
          String fileoopath = transformPathForOpenOffice(fileTmpImg);
          logger.debug("Path image loaded into openoffice = " + fileoopath);
          String externalGraphicUrl = "file:///" + fileoopath;
          if (!oBitmaps.hasByName(nameImg)) {
        logger.debug("Bitmap table does not contain an element with name '" + nameImg
          + "'.");
        oBitmaps.insertByName(nameImg, externalGraphicUrl);
          } else {
        logger.debug("Bitmap table already contains an element with name '" + nameImg
          + "'.");
          }
          Object internalGraphicUrl = oBitmaps.getByName(nameImg);
          logger.debug("Retrieved internal url for image '" + nameImg + "': "
            + internalGraphicUrl);
          xSPS.setPropertyValue("GraphicURL", internalGraphicUrl);
      } catch (Exception e) {
        logger.error("error while adding graphic shape", e);
      }
      shapetoadd.add(xShapeNew);
      logger.debug("New shape loaded on shapes to be added");
        }
    }
    // add and remove shape
    Iterator iter = shapetoremove.iterator();
    while (iter.hasNext()) {
        XShape shape = (XShape) iter.next();
        xShapes.remove(shape);
    }
    logger.debug("Removed shapes to be removed from document");
    iter = shapetoadd.iterator();
    while (iter.hasNext()) {
        XShape shape = (XShape) iter.next();
        xShapes.add(shape);
    }
    logger.debug("Added shapes to be added to the document");
    // add notes
    XPresentationPage xPresPage = (XPresentationPage) UnoRuntime.queryInterface(XPresentationPage.class,
      xDrawPage);
    XDrawPage notesPage = xPresPage.getNotesPage();
    logger.debug("Notes page retrieved: " + notesPage);
    XShapes xShapesNotes = (XShapes) UnoRuntime.queryInterface(XShapes.class, notesPage);
    logger.debug("Shape notes retrieved: " + xShapesNotes);
    int numNoteShapes = xShapesNotes.getCount();
    logger.debug("Number of shape notes: " + numNoteShapes);
    for (int indShap = 0; indShap < numNoteShapes; indShap++) {
        logger.debug("Start examining shape note number " + indShap + " of page " + i);
        Object shapeNoteObj = xShapesNotes.getByIndex(indShap);
        XShape xshapeNote = (XShape) UnoRuntime.queryInterface(XShape.class, shapeNoteObj);
        logger.debug("xshapeNote: " + xshapeNote);
        String type = xshapeNote.getShapeType();
        logger.debug("Shape type: " + type);
        if (type.endsWith("NotesShape")) {
      XText textNote = (XText) UnoRuntime.queryInterface(XText.class, shapeNoteObj);
      logger.debug("XText: " + textNote);
      byte[] notesByte = dptDAO.getNotesOfDossierPart(dossierId, pageNum, workflowProcessId);
      String notes = null;
      if (notesByte == null) {
          logger.debug("Notes bytes array is null!!!!");
          notes = "";
      } else {
          logger.debug("Notes bytes array retrieved");
          notes = new String(notesByte);
      }
      textNote.setString(notes);
      logger.debug("Notes applied to the XText");
        }
    }
      }

      // save final document
      String pathFinalDoc = tempFolder + "/" + dossier.getName() + ".ppt";
      logger.debug("Path final document = " + pathFinalDoc);
      File fileFinalDoc = new File(pathFinalDoc);
      String fileoopath = transformPathForOpenOffice(fileFinalDoc);
      logger.debug("Open Office path: " + fileoopath);
      if (fileoopath.equals(""))
    return;
      XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xComponent);
      logger.debug("XStorable: " + xStorable);
      PropertyValue[] documentProperties = new PropertyValue[2];
      documentProperties[0] = new PropertyValue();
      documentProperties[0].Name = "Overwrite";
      documentProperties[0].Value = new Boolean(true);
      documentProperties[1] = new PropertyValue();
      documentProperties[1].Name = "FilterName";
      documentProperties[1].Value = "MS PowerPoint 97";
      try {
        logger.debug("Try to store document with path = " + "file:///" + fileoopath);
        xStorable.storeAsURL("file:///" + fileoopath, documentProperties);
        logger.debug("Document stored with path = " + "file:///" + fileoopath);
      } catch (IOException e) {
        logger.error("Error while storing the final document", e);
      }
      FileInputStream fis = new FileInputStream(pathFinalDoc);
      byte[] docCont = GeneralUtilities.getByteArrayFromInputStream(fis);
      IDossierPresentationsDAO dpDAO = DAOFactory.getDossierPresentationDAO();
     
      DossierPresentation dossierPresentation = new DossierPresentation();
      dossierPresentation.setApproved(null);
      dossierPresentation.setProg(null);
      dossierPresentation.setBiobjectId(dossier.getId());
      dossierPresentation.setContent(docCont);
      dossierPresentation.setName(dossier.getName());
      dossierPresentation.setWorkflowProcessId(workflowProcessId);
      dpDAO.insertPresentation(dossierPresentation);
      logger.debug("Document stored.");
      fis.close();
      dptDAO.cleanDossierParts(dossierId, workflowProcessId);
      logger.debug("Dossier temporary parts relevant to document id = [" + dossierId + "] " +
          "and workflow process id = [" + workflowProcessId + "] deleted.");
  } catch (Exception e) {
    logger.error("Error during the generation of the final document", e);
      // AUDIT UPDATE
View Full Code Here

Examples of it.eng.spagobi.engines.dossier.dao.IDossierPartsTempDAO

  }
 
 
 
  private String recoverNotes(Integer dossierId, int pageNum, Long workflowProcessId) throws Exception {
    IDossierPartsTempDAO dptDAO = DAOFactory.getDossierPartsTempDAO();
      byte[] notesByte =   dptDAO.getNotesOfDossierPart(dossierId, pageNum, workflowProcessId);
      String notes = notesByte != null ? new String(notesByte) : "";
      return notes;
  }
View Full Code Here

Examples of it.eng.spagobi.engines.dossier.dao.IDossierPartsTempDAO

  }
 
 
 
  private Map recoverImageUrls(Integer dossierId, int pageNum, Long workflowProcessId) throws Exception {
    IDossierPartsTempDAO dptDAO = DAOFactory.getDossierPartsTempDAO();
    Map images = dptDAO.getImagesOfDossierPart(dossierId, pageNum, workflowProcessId);
    File tempDir = DossierDAOHibImpl.tempBaseFolder;
    tempDir.mkdirs();
    // for each image store into the temp directory and save the url useful to recover it into the map
      Map imageurl = new HashMap();
      Iterator iterImgs = images.keySet().iterator();
View Full Code Here

Examples of it.eng.spagobi.engines.dossier.dao.IDossierPartsTempDAO

      ProcessInstance processInstance = contextInstance.getProcessInstance();
      Long workflowProcessId = new Long(processInstance.getId());
      SessionContainer session = this.getRequestContainer().getSessionContainer();
      SessionContainer permanentSession = session.getPermanentContainer();
      IEngUserProfile profile = (IEngUserProfile) permanentSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
      IDossierPartsTempDAO dptDAO = DAOFactory.getDossierPartsTempDAO();
      dptDAO.setUserProfile(profile);
      dptDAO.storeNote(dossierId, pageNum, noteSent.getBytes(), workflowProcessId);
      // recover from cms images and notes
        String notes = recoverNotes(dossierId, pageNum, workflowProcessId);
        Map imageurl = recoverImageUrls(dossierId, pageNum, workflowProcessId);
      // put attributes into response
      response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierEditNotesTemplatePart");
View Full Code Here

Examples of it.eng.spagobi.engines.dossier.dao.IDossierPartsTempDAO

      logger.debug("base 64 encoded image bytes retrived " + firstImgBase64);
      BASE64Decoder decoder = new BASE64Decoder();
      byte[] firstImg = decoder.decodeBuffer(firstImgBase64);
      logger.debug("image bytes decoded " + firstImg);
      // store image into cms
      IDossierPartsTempDAO dptDAO = DAOFactory.getDossierPartsTempDAO();
      dptDAO.setUserProfile(profile);
      dptDAO.storeImage(dossier.getId(), firstImg, confDoc.getLogicalName(), numPage, workflowProcessId);
      logger.debug("image stored into cms");
  } catch (Exception e) {
      logger.error("Error while generating and storing " + "images of the document"
        + confDoc.getLogicalName() + " \n " + e);
      throw e;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.