Package es.ipsa.atril.doc.user

Examples of es.ipsa.atril.doc.user.Document


      StreamPipe oPipe;
      try {
        oSes = DAO.getAdminSession("ThumbnailCreator");
        oSes.autoCommit(true);
        Dms oDms = oSes.getDms();
        Document oDoc = oDms.getDocument(sParent);
        Item oItm = oDms.getDocument(sItem).item();
        String sFileName = oItm.name().toLowerCase();
        oPipe = new StreamPipe();
        ByteArrayOutputStream oByOut = new ByteArrayOutputStream();
        if (sFileName.endsWith(".pdf")) {
          Log.out.debug("Item.getInputStreamTranscodedToMime(image/jpeg)");
          oPipe.between(oItm.getInputStreamTranscodedToMime("image/jpeg"), oByOut);
        } else {
            Log.out.debug("Item.getInputStream()");
            oPipe.between(oItm.getInputStream(), oByOut);         
        }
        byte[] aBytes = oByOut.toByteArray();
        oByOut.close();
        oByOut = null;
        Log.out.debug("new Picture()");
        Picture oPic = new Picture();
        Log.out.debug("Before Picture.dimensions()");
        int[] aWidthHeight = oPic.dimensions(aBytes, "jpeg");
        Log.out.debug("After Picture.dimensions()");
        if (null==aWidthHeight)
          throw new NullPointerException("Unable to get dimensions for image "+oItm.name());
        Log.out.debug("Image width="+String.valueOf(aWidthHeight[0])+" height="+String.valueOf(aWidthHeight[1]));
        int iWidth, iHeight;
        if (aWidthHeight[0]<=MaxWidth && aWidthHeight[0]<=MaxHeight) {
          iWidth = aWidthHeight[0];
          iHeight = aWidthHeight[1];
        } else {
          float fWidthRatio = ((float) aWidthHeight[0]) / MaxWidth;
          float fHeightRatio = ((float) aWidthHeight[1]) / MaxHeight;
          if (fWidthRatio>fHeightRatio) {
            iWidth = (int) MaxWidth;
            iHeight = (int) (MaxWidth*aWidthHeight[1])/aWidthHeight[0];
          } else {
            iWidth = (int) (aWidthHeight[0]*MaxHeight)/aWidthHeight[1];
            iHeight = (int) MaxHeight;
          }
        }
        Log.out.debug("Resampled width="+String.valueOf(iWidth)+" height="+String.valueOf(iHeight));
        String sCodec = null;
        if (sFileName.endsWith(".jpg") || sFileName.endsWith(".jpeg") || sFileName.endsWith(".pdf"))
          sCodec = "jpeg";
        else if (sFileName.endsWith(".gif"))
          sCodec = "gif";
        else if (sFileName.endsWith(".tif") || sFileName.endsWith(".tiff"))
          sCodec = "tiff";
        else {
          Log.out.error("ThumbnailCreator.run()  Could not find suitable codec for file "+oItm.name());
          throw new InstantiationException("Could not find suitable codec for file "+oItm.name());
        }
        Log.out.debug("Picture.createThumbBitmap("+sCodec+","+String.valueOf(iWidth)+","+String.valueOf(iHeight)+",80)");
        byte[] byThumb = oPic.createThumbBitmap(aBytes, sCodec, iWidth, iHeight, 80);
       
        Document oThl = oDms.newDocument(oDms.getDocumentType(oDoc.type().name()+"Thumbnail"), oDoc);
        AttributeMultiValue oAtr = oThl.attribute("width");
      oAtr.set((long) iWidth);
      oAtr = oThl.attribute("height");
      oAtr.set((long) iHeight);
      oThl.save("");
        Item oThi = oThl.item();
        String sItemName = "th"+oDoc.id()+".jpg";
        oThi.setName(sItemName);
        oThi.mimeType("image/jpeg");
        OutputStream oOutStrm = oThi.getOutputStream();
        oPipe = new StreamPipe();
        oPipe.between(new ByteArrayInputStream(byThumb), oOutStrm);
        oThl.save("");
        oOutStrm.close();
        Log.out.debug("Thumbnail creation done");
        DAO.log(oSes, oThl, Class.forName("com.zesped.model."+oDoc.type().name()+"Thumbnail"), "INSERT THUMBNAIL", AtrilEvent.Level.INFO, sItemName);
        oSes.disconnect();
        oSes.close();
View Full Code Here


    if (null==sEmployeeUuid) throw new NullPointerException("BillNote.create() employee may not be bull");
    final String sSanitizedConcept = Gadgets.removeChars(sConcept,"\"\n'");
    if (sConcept.length()==0) throw new NullPointerException("BillNote.create() concept may not be empty");
    if (sEmployeeUuid.length()==0) throw new NullPointerException("BillNote.create() employee may not be empty");
    Employee emee = new Employee();
    Document dmee = emee.exists(oSes, "employee_uuid", sEmployeeUuid);
    if (null==dmee)
      throw new ElementNotFoundException("BillNotes.create()  Employee "+sEmployeeUuid+" not found");
    emee.setDocument(dmee);
    Log.out.debug("got employee "+sEmployeeUuid);
    BillNote bill = new BillNote(oSes, this);
View Full Code Here

    Dms oDms = oSes.getDms();
    SortableList<Document> oLst = (SortableList<Document>) oDms.query("BillNote & (($taxpayer='" + sTaxPayerId + "')"+(bOnlyOpen ? " & ($is_open='1')" : "")+")");
    TreeSet<String> oSet = new TreeSet<String>();
    ArrayList<Concept> oCps = new ArrayList<Concept>();
    for (Document d : oLst) {
      Document b = oDms.getDocument(d.id());
      AttributeMultiValue a = b.attribute("concept");
      AttributeMultiValue t = b.attribute("creation_date");
      AttributeMultiValue e = b.attribute("employee_uuid");
      if (a!=null) {
        Concept c;
        try {
          Log.out.debug("concept "+a.toString());
          Log.out.debug("given employee UUID "+sEmployeeUuid);
View Full Code Here

      if (getRecipientTaxPayer().length()==0) {
        errors.add("items", new LocalizableError("com.zesped.action.InvoceUpload.clientIsRequired"));
      } else if (getBillerTaxPayer().length()>0) {
        connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
        Dms oDms = getSession().getDms();
        Document r,b;
        try {
          r = oDms.getDocument(getRecipientTaxPayer());
          try {
          b = oDms.getDocument(getBillerTaxPayer());
          if (r.type().name().equals(b.type().name()))
            errors.add("items", new LocalizableError("com.zesped.action.InvoceUpload.incompatibleClientAndSupplier"));
          } catch (NumberFormatException nfe) {
          Log.out.error("NumberFormatException getting biller "+getBillerTaxPayer(), nfe);
          errors.add("items", new LocalizableError("com.zesped.action.InvoceUpload.incompatibleClientAndSupplier"));
            }
View Full Code Here

      Log.out.debug("InvoiceUpload "+String.valueOf(nItems)+" items found");
      try {
        connect(getSessionAttribute("nickname"), getSessionAttribute("password"));

        Dms oDms = getSession().getDms();
        Document rcpt = oDms.getDocument(getRecipientTaxPayer());
        String sTaxPayerId = rcpt.type().name().equals("TaxPayer") ? getRecipientTaxPayer() : getSessionAttribute("taxpayer_docid");
        TaxPayer txpy = new TaxPayer(getSession().getDms(), sTaxPayerId);

        Invoices invs = txpy.invoices(getSession());
       
        invc = invs.create(getSession(), getSessionAttribute("user_uuid"), getServiceFlavor(),
View Full Code Here

      Log.out.error("E-mail address "+getEmail()+" already belongs to another user");
      throw new IllegalArgumentException("E-mail address "+getEmail()+" already belongs to another user");
    }
   
    Dms oDms = oSes.getDms();
    Document oDoc = oDms.newDocument(oDms.getDocumentType("User"), oDms.getDocument(sUsrs));
    oDoc.save("");
    setDocument(oDoc);
   
    AttributeMultiValue oUid = oDoc.attribute("user_id");
    oUid.set(oDoc.id());
    AttributeMultiValue oUuid = oDoc.attribute("user_uuid");
    oUuid.set(sNickName);
    AttributeMultiValue oAttr = oDoc.attribute("email");
    oAttr.set(getEmail());
    AttributeMultiValue oActv = oDoc.attribute("active");
    oActv.set(getStringNull("active","1"));
    AttributeMultiValue oSrvs = oDoc.attribute("allowed_services");
    oSrvs.set(String.valueOf(CaptureService.INVOICES.toInt())+","+String.valueOf(CaptureService.BILLNOTES.toInt()));
    AttributeMultiValue oPassw = oDoc.attribute("password");
    oPassw.set(ACL.encript(getPassword(), ACL.PWD_DTIP_RC4_64));
    AttributeMultiValue oApr = oDoc.attribute("can_approve");
    oApr.set("1");
    AttributeMultiValue oStl = oDoc.attribute("can_settle");
    oStl.set("1");
    AttributeMultiValue oPre = oDoc.attribute("can_premium");
    oPre.set("1");
    oDoc.save("");
    oIdx.indexDocument(oDoc);

    put("user_id", oDoc.id());
    put("user_uuid", sNickName);
    put("can_approve", "1");
    put("can_settle", "1");
    put("can_premium", "1");
    put("active", getStringNull("active","1"));
    put("allowed_services", String.valueOf(CaptureService.INVOICES.toInt())+","+String.valueOf(CaptureService.BILLNOTES.toInt()));

    es.ipsa.atril.sec.user.User oUsr = oAum.getUser(getNickName());
   
    oAum.setDocumentRights(oUsr, oDoc, RightsFactory.getDocumentRightsAllGrant());

    try {
      oAum.setDocumentRights(oUsr, Deposits.top(oSes).getDocument(), RightsFactory.getDocumentRightsAllGrant());
    } catch (ElementNotFoundException ignore) { }
   
    DAO.log(oSes, oDoc, User.class, "CREATE USER", AtrilEvent.Level.INFO, String.valueOf(getAdministeredUser().getId())+";"+getEmail());

    Log.out.debug("End com.zesped.model.User.create() : "+oDoc.id());
  }
View Full Code Here

        oObj = new AllowedTaxPayer();
      else if (sType.equals("DeniedTaxPayer"))
        oObj = new DeniedTaxPayer();
      else
        throw new IllegalArgumentException("Unrecognized type "+sType);       
      Document t = oObj.exists(oSes, "taxpayer", sTaxPayerId);
      if (t!=null) {
        BaseCompanyObject.delete(oSes, t.id());
      }
    }
  }
View Full Code Here

    try {
      oCon = DAO.getConnection("DepositToZespedBridge");
      oCon.setAutoCommit(false);
      oStm = oCon.prepareStatement("UPDATE Documento SET fkIdDocPadre=? WHERE IdDoc=?");
      Dms oDms = oSes.getDms();
      Document oDepo = oDms.getDocument(String.valueOf(lDepositId));
      Document oDdoc = oDepo.children().get(0);
      Document oBble = oDms.getDocument(String.valueOf(lBillableId))

      Log.out.debug("getting sides for document "+oDdoc.id());
           
      for (Document oSide : oDdoc.children()) {
        oStm.setLong(1, Long.parseLong(oBble.id()));
        oStm.setLong(2, Long.parseLong(oSide.id()));
        Log.out.debug("UPDATE documento SET fkIdDocPadre="+oBble.id()+" WHERE IdDoc="+oSide.id());
        oStm.executeUpdate();
        aSides.add(oSide);
        ThumbnailCreator.createThumbnailFor(oBble.id(), oSide.id());
      }
      oStm.close();
      oStm=null;
      oCon.commit();
      oCon.close();
View Full Code Here

  }

  // ---------------------------------------------------------------------------

  private Document createDocumentOfType(DocumentIndexer oIdx, Dms oDms, String sTypeName, Document oParentDoc) {
    Document oDoc;
    SortableList<Document> oLst = oDms.query(sTypeName);
    if (oLst.isEmpty()) {
    oDoc = oDms.newDocument(oDms.getDocumentType(sTypeName), oParentDoc);
    oDoc.save("");
    oIdx.indexDocument(oDoc);
    } else {
    oDoc = oLst.get(0);
    }
    return oDoc;
View Full Code Here

        oCon.setAutoCommit(false);
        oStm = oCon.prepareStatement("UPDATE Documento SET fkIdDocPadre=? WHERE IdDoc=?");
        Dms oDms = oSes.getDms();
        TaxPayer txpy = new TaxPayer(oDms, sTaxPayerId);
        Invoices invs = txpy.invoices(oSes);
        Document oDepo = oDms.getDocument(String.valueOf(lDepositId));
        for (Document oDdoc : oDepo.children()) {
          Log.out.debug("getting sides for document "+oDdoc.id());
          NodeList<Document> oChlds = oDdoc.children();
          Invoice[] aInvs = invs.create(oSes, sUid, sFlavor, sTaxPayerId, sBiller, sRecipient, oChlds.size());
          int i = 0;
          for (Document oSide : oChlds) {
View Full Code Here

TOP

Related Classes of es.ipsa.atril.doc.user.Document

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.