Package es.ipsa.atril.documentindexer

Examples of es.ipsa.atril.documentindexer.DocumentIndexer


    } // next
   
    if (null==oAccountingAccounts) {
      Document n = oSes.getDms().newDocument(oSes.getDms().getDocumentType("AccountingAccounts"), getDocument());
      n.save("");
      DocumentIndexer oIdx = oSes.getDocumentIndexer();
      oIdx.indexDocument(n);
      oAccountingAccounts = new AccountingAccounts(n);
      populateAccountingAccountsWithDefaultValues(oSes, oSes.getDms(), oIdx, customerAccount(oSes.getDms()));
    }
    return oAccountingAccounts;
  }
View Full Code Here


 
  public QueryResultSet<BillNote> queryBillNotes(AtrilSession oSes, Boolean bOpen, String sEmployee, String sConcept, String sSearchStr, int iMaxRows, int iOffset)
    throws DocumentIndexerException {
    QueryResultSet<BillNote> aLst = new QueryResultSet<BillNote>();
    Dms oDms = oSes.getDms();
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
    String sQry = DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "BillNote AND taxpayer:\""+id()+"\"";
    if (bOpen!=null)
      sQry += " AND is_open:\""+(bOpen.booleanValue() ? "1" : "0")+"\"";
    if (sEmployee!=null) {
      if (sEmployee.length()>0) {
        sQry += " AND (employee_uuid:\""+sEmployee+"\" OR employee_id:\""+sEmployee+"*\")";
      }
    }
    if (sConcept!=null) {
      if (sConcept.length()>0) {
        sQry += " AND concept:\""+Gadgets.removeChars(sConcept,"\"\n'")+"\"";
      }
    }
    if (sSearchStr!=null) {
      if (sSearchStr.length()>0) {
        String sSanitizedSearchStr = Gadgets.removeChars(sSearchStr,"\"\n'");
        sQry += " AND (concept:\""+sSanitizedSearchStr+"\"* OR employee_name:\""+sSanitizedSearchStr+"\"* OR comments:\""+sSanitizedSearchStr+"\"*)";
      }
    }
    SortableList<Document> oLst = (SortableList<Document>) oIdx.query(sQry);
    if (!oLst.isEmpty()) {
      int o = 0, n = 0;
      for (Document d : oLst) {
        if (iOffset<=o++) {
          try {
View Full Code Here

                         String sBiller, String sConcept, String sSearchStr, int iMaxRows, int iOffset)
    throws DocumentIndexerException {
    Log.out.debug("Begin TaxPayer.queryTickets("+bProcessed+","+bHasMistakes+","+bOnlyOpen+","+aAmountRange+","+aMonthsRange+","+aYearsRange+","+sBiller+","+sSearchStr+","+String.valueOf(iMaxRows)+","+String.valueOf(iOffset)+")");
    QueryResultSet<Ticket> aLst = new QueryResultSet<Ticket>();
    Dms oDms = oSes.getDms();
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
    if (aAmountRange==null && aMonthsRange==null && aYearsRange==null)
      oIdx.setMaximumNumberOfDocumentReturned(iOffset+iMaxRows);
    String sQry = DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "Ticket AND taxpayer:\""+id()+"\"";
    if (bOnlyOpen!=null)
      sQry += " AND is_open:\""+(bOnlyOpen.booleanValue() ? "1" : "0")+"\"";
    if (bProcessed!=null)
        sQry += " AND is_processed:\""+(bProcessed.booleanValue() ? "1" : "0")+"\"";
    if (bHasMistakes!=null)
        sQry += " AND has_mistakes:\""+(bHasMistakes.booleanValue() ? "1" : "0")+"\"";
    if (sBiller!=null)
      if (sBiller.length()>0)
        sQry += " AND biller_taxpayer:\""+sBiller+"\"";
    if (sConcept!=null) {
      if (sConcept.length()>0) {
        sQry += " AND concept:\""+sConcept +"\"";
      }
    }
    if (sSearchStr!=null) {
      if (sSearchStr.length()>0) {
        String sSanitizedSearchStr = Gadgets.removeChars(sSearchStr, "\"\n");
        sQry += " AND (ticket_number:\""+sSanitizedSearchStr +"\" OR concept:\""+sSanitizedSearchStr +"*\" OR comments:\""+sSanitizedSearchStr +"*\")";
      }
    }
    Log.out.debug("DocumentIndexer.query("+sQry+")");
    SortableList<Document> oLst = (SortableList<Document>) oIdx.query(sQry);
    if (!oLst.isEmpty()) {
      int o = 0, n = 0;
      for (Document d : oLst) {
        if (iOffset<=o++) {
          try {
View Full Code Here

  public QueryResultSet<Invoice> queryInvoices(AtrilSession oSes, Boolean bProcessed, Boolean bApproved, Boolean bHasMistakes, BigDecimal[] aAmountRange, Integer[] aMonthsRange, Integer[] aYearsRange, String sRecipient, String sBiller, String sServiceFlavor, String sSearchStr, int iMaxRows, int iOffset)
    throws DocumentIndexerException {
    Log.out.debug("Begin TaxPayer.queryInvoices("+bProcessed+","+bApproved+","+bHasMistakes+","+aAmountRange+","+aMonthsRange+","+aYearsRange+","+sBiller+","+sSearchStr+","+String.valueOf(iMaxRows)+","+String.valueOf(iOffset)+")");
    QueryResultSet<Invoice> aLst = new QueryResultSet<Invoice>();
    Dms oDms = oSes.getDms();
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
    if (aAmountRange==null && aMonthsRange==null && aYearsRange==null)
      oIdx.setMaximumNumberOfDocumentReturned(iOffset+iMaxRows);

    String sQry = DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "Invoice AND taxpayer:\""+id()+"\"";
    if (bProcessed!=null)
        sQry += " AND is_processed:\""+(bProcessed.booleanValue() ? "1" : "0")+"\"";
    if (bApproved!=null)
        sQry += " AND is_approved:\""+(bApproved.booleanValue() ? "1" : "0")+"\"";
    if (bHasMistakes!=null)
        sQry += " AND has_mistakes:\""+(bHasMistakes.booleanValue() ? "1" : "0")+"\"";
    if (sRecipient!=null)
      if (sRecipient.length()>0)
        sQry += " AND recipient_taxpayer:\""+sRecipient+"\"";
    if (sBiller!=null)
      if (sBiller.length()>0)
        sQry += " AND biller_taxpayer:\""+sBiller+"\"";
    if (sServiceFlavor!=null) {
      if (sServiceFlavor.length()>0) {
        sQry += " AND service_type:\""+sServiceFlavor+"\"";
      }
    }
    if (sSearchStr!=null) {
      if (sSearchStr.length()>0) {
        String sSanitizedSearchStr = Gadgets.removeChars(sSearchStr, "\"\n");
        sQry += " AND (invoice_number:\""+sSanitizedSearchStr +"\" OR concept:\""+sSanitizedSearchStr +"*\" OR comments:\""+sSanitizedSearchStr +"*\")";
      }
    }
   
    Log.out.debug("DocumentIndexer.query("+sQry+")");
    SortableList<Document> oLst = (SortableList<Document>) oIdx.query(sQry);
    if (!oLst.isEmpty()) {
      int o = 0, n = 0;
      for (Document d : oLst) {
        if (iOffset<=o++) {
          try {
View Full Code Here

  public static TaxPayer create(AtrilSession oSes, CustomerAccount oAcc, String sBusinessName, String sTaxId, String sContactPerson, String sEmail, boolean bRequiresActivation, String sVolumesMountBase)
    throws NullPointerException, IllegalArgumentException, ElementNotFoundException, NotEnoughRightsException, DmsException, InstantiationException, IllegalStateException, IllegalAccessException,
         FileNotFoundException, IOException, Exception {
    Dms oDms = oSes.getDms();
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
   
    Log.out.debug("Begin TaxPayer.create("+sBusinessName+","+sTaxId+","+sEmail+String.valueOf(bRequiresActivation)+","+sVolumesMountBase+")");
   
    long lEnd, lStart = new Date().getTime();
   
    TaxPayer oPayer = new TaxPayer();
    oPayer.setDocument(oDms.newDocument(oDms.getDocumentType("TaxPayer"), oAcc.taxpayers(oSes).getDocument()));
    oPayer.put("customer_acount", oAcc.getString("account_id"));
    oPayer.put("creation_date", new Date());
    oPayer.put("active", bRequiresActivation ? "-1" : "1");
    oPayer.put("business_name", sBusinessName);
    oPayer.put("tax_id", sTaxId);
    oPayer.put("contact_person", sContactPerson);
    oPayer.put("email", sEmail);
    oPayer.save(oSes);

    oSes.commit();

    Log.out.debug("PROFILING: Save TaxPayer "+String.valueOf((lEnd=new Date().getTime())-lStart)+" ms");
    lStart = lEnd;
   
    Document oInvoices = oDms.newDocument(oDms.getDocumentType("Invoices"), oPayer.getDocument());
    oInvoices.save("");
    oIdx.indexDocument(oInvoices);

    Document oBillNotes = oDms.newDocument(oDms.getDocumentType("BillNotes"), oPayer.getDocument());
    oBillNotes.save("");
    oIdx.indexDocument(oBillNotes);

    Document oEmployees = oDms.newDocument(oDms.getDocumentType("Employees"), oPayer.getDocument());
    oEmployees.save("");
    oIdx.indexDocument(oEmployees);

    Log.out.debug("PROFILING: Create TaxPayer child documents "+String.valueOf((lEnd=new Date().getTime())-lStart)+" ms");
    lStart = lEnd;
   
    oAcc.grant(oSes, oPayer.getDocument(), oInvoices, oBillNotes);
View Full Code Here

    if (oDoc==null) throw new IllegalStateException(getTypeName()+" document not set before calling save() method");

    if (DAO.checkConstraints) {
      AtrilSession oAdm = DAO.getAdminSession("checkConstraints");
      Dms oDms = oAdm.getDms();
      DocumentIndexer oIdx = oAdm.getDocumentIndexer();
      final Attr[] aAttrs = attributes();
      final int nAttrs = (aAttrs==null ? 0 : aAttrs.length);
      try {
        for (int a=0; a<nAttrs; a++) {
          if (aAttrs[a].required && isNull(aAttrs[a].name)) throw new NullPointerException(getTypeName()+" attribute "+aAttrs[a].name+" is required");
View Full Code Here

    else
      return oLst.get(0);   
  }

  public Document exists(AtrilSession oSes, NameValuePair... aNvp) throws DocumentIndexerException {
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
    oIdx.setMaximumNumberOfDocumentReturned(1);
    String sQry = DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + getTypeName();
    for (NameValuePair oNvp : aNvp)
      sQry += " AND "+oNvp.getName()+"=\""+oNvp.getValue()+"\"";
    SortableList<Document> oLst = (SortableList<Document>) oIdx.query(sQry);
    if (oLst.isEmpty())
      return null;
    else
      return oLst.get(0);   
  }
View Full Code Here

    if (oLst.isEmpty()) throw new ElementNotFoundException("Could not find any CustomerAccount with unique id "+sUuid);
    return new CustomerAccount(oDms.getDocument(oLst.get(0).id()));
  }
 
  public static List<CustomerAccount> search(AtrilSession oSes, String sNameOrId) {
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
    oIdx.setMaximumNumberOfDocumentReturned(50);
    String sSanitizedNameOrId = Gadgets.removeChars(sNameOrId, "\"*?").trim();
    SortableList<Document> oLst = (SortableList<Document>) oIdx.query("(business_name:\"" + sSanitizedNameOrId + "\" OR tax_id:\""+sNameOrId+"\") AND " + DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "CustomerAccount");
    if (oLst.isEmpty()) {
      int i1stWord = sSanitizedNameOrId.indexOf(' ');
      if (i1stWord>0) sSanitizedNameOrId = sSanitizedNameOrId.substring(0, i1stWord);
      oLst = (SortableList<Document>) oIdx.query("(business_name:" + sNameOrId + "* AND " + DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "CustomerAccount", "business_name");
      if (oLst.isEmpty()) {
        oLst = (SortableList<Document>) oIdx.query("(business_name:" + sNameOrId + "~ AND " + DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "CustomerAccount", "business_name");
      }
    }
    ArrayList aLst = new ArrayList();
    for (Document d : oLst) {
      CustomerAccount oAcc = new CustomerAccount();
View Full Code Here

    CustomerAccount oNew = new CustomerAccount();

    Date dtNow = new Date();
   
    DocumentIndexer oIdx = oSes.getDocumentIndexer();

    long lEnd, lStart = new Date().getTime();
   
    SortableList<Document> oLst = (SortableList<Document>) oIdx.query("business_name:\"" + sBusinessName + "\" AND " + DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "CustomerAccount");
    if (!oLst.isEmpty()) throw new IllegalArgumentException(sBusinessName+" already exists");

    Log.out.debug("PROFILING: Search Business Name "+String.valueOf((lEnd=new Date().getTime())-lStart)+" ms");
    lStart = lEnd;
   
    Dms oDms = oSes.getDms();
    oNew.setDocument (oDms.newDocument(oDms.getDocumentType(oNew.getTypeName()), Zesped.top(oSes).getDocument()));
    oNew.put("account_id",Gadgets.generateUUID());
    oNew.put("active","1");
    oNew.put("business_name",sBusinessName);
    oNew.put("creation_date", dtNow);
    oNew.put("contact_person", oUsr.getFirstName()+" "+oUsr.getLastName());
    oNew.save(oSes);

    Log.out.debug("PROFILING: Save CustomerAccount "+String.valueOf((lEnd=new Date().getTime())-lStart)+" ms");
    lStart = lEnd;
   
    Log.out.debug("CustomerAccount.createGroups(AtrilSession)");

    oNew.createGroups(oSes);

    Log.out.debug("PROFILING: Create permissions groups "+String.valueOf((lEnd=new Date().getTime())-lStart)+" ms");
    lStart = lEnd;
   
    oNew.grantAdmin(oSes, oUsr);

    Log.out.debug("PROFILING: Grant admin permissions "+String.valueOf((lEnd=new Date().getTime())-lStart)+" ms");
    lStart = lEnd;
   
    AttributeMultiValue oAttr = oUsr.getDocument().attribute("customer_acount");
    oAttr.set(oNew.getUuid());
    oUsr.getDocument().save("");
    oIdx.indexDocument(oUsr.getDocument());

    Document oOrders = oDms.newDocument(oDms.getDocumentType("Orders"), oNew.getDocument());
    oOrders.save("");
    oIdx.indexDocument(oOrders);
   
    Document oClients = oDms.newDocument(oDms.getDocumentType("Clients"), oNew.getDocument());
    oClients.save("");
    oIdx.indexDocument(oClients);

    Document oPayers = oDms.newDocument(oDms.getDocumentType("TaxPayers"), oNew.getDocument());
    oPayers.save("");
    oIdx.indexDocument(oPayers);

    Document oCredits = oDms.newDocument(oDms.getDocumentType("CustomerAccountCredits"), oNew.getDocument());
    oCredits.attribute("account_id").set(oNew.getString("account_id"));
    oCredits.attribute("credits_used").set(0l);
    oCredits.attribute("credits_left").set(0l);
    oCredits.save("");
    oIdx.indexDocument(oCredits);
   
    Log.out.debug("PROFILING: Create CustomerAccount child documents "+String.valueOf((lEnd=new Date().getTime())-lStart)+" ms");
    lStart = lEnd;
   
    oNew.grant(oSes, oNew.getDocument(), oOrders, oClients, oPayers);
View Full Code Here

 
  public QueryResultSet<Ticket> queryTickets(AtrilSession oSes, Boolean bProcessed, Boolean bHasMistakes, Boolean bOnlyOpen, BigDecimal[] aAmountRange, Integer[] aMonthsRange, Integer[] aYearsRange, String sBiller, String sSearchStr, int iMaxRows, int iOffset)
    throws DocumentIndexerException {
    QueryResultSet<Ticket> aLst = new QueryResultSet<Ticket>();
    Dms oDms = oSes.getDms();
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
    if (aAmountRange==null && aMonthsRange==null && aYearsRange==null)
      oIdx.setMaximumNumberOfDocumentReturned(iOffset+iMaxRows);
    String sQry = DocumentIndexer.AdditionalDocumentFields.DOCUMENT_TYPE_NAME.value() + ":" + "Ticket AND employee_uuid:\""+getUuid()+"\" AND taxpayer:\""+getTaxPayer(oSes).id()+"\"";
    if (bProcessed!=null)
        sQry += " AND is_processed:\""+(bProcessed.booleanValue() ? "1" : "0")+"\"";
    if (bHasMistakes!=null)
        sQry += " AND has_mistakes:\""+(bHasMistakes.booleanValue() ? "1" : "0")+"\"";
    if (bOnlyOpen!=null)
        sQry += " AND is_open:\""+(bOnlyOpen.booleanValue() ? "1" : "0")+"\"";
    if (sBiller!=null)
      if (sBiller.length()>0)
        sQry += " AND biller_taxpayer:\""+sBiller+"\"";
    if (sSearchStr!=null) {
      if (sSearchStr.length()>0) {
        String sSanitizedSearchStr = Gadgets.removeChars(sSearchStr, "\"\n");
        sQry += " AND (ticket_number:\""+sSanitizedSearchStr +"\" OR concept:\""+sSanitizedSearchStr +"\" OR comments:\""+sSanitizedSearchStr +"\")";
      }
    }
    SortableList<Document> oLst = (SortableList<Document>) oIdx.query(sQry);
    if (!oLst.isEmpty()) {
      int o = 0, n = 0;
      for (Document d : oLst) {
        if (iOffset<=o++) {
          try {
View Full Code Here

TOP

Related Classes of es.ipsa.atril.documentindexer.DocumentIndexer

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.