Package es.ipsa.atril.doc.user

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


    clear();
    final Attr[] aAttrs = attributes();
    if (aAttrs!=null) {
      final int nAttrs = aAttrs.length;
      for (int a=0; a<nAttrs; a++) {
        AttributeMultiValue oAttr = oDoc.attribute(aAttrs[a].name);
        try {
          if (oAttr!=null) {
            if (oAttr.count()==1) {
              switch (oAttr.dataType()) {
              case STRING:
                put(aAttrs[a].name, oAttr.toString());
                break;
              case NUMBER:
                put(aAttrs[a].name, oAttr.toBigDecimal());
                break;
              case DATE:
                put(aAttrs[a].name, oAttr.toDate());
                break;
              case DATE_TIME:
                long lValue;
                try {
                  lValue = oAttr.toLong();
                  Log.out.info("Got long value "+String.valueOf(lValue));
                  if (lValue!=-1l)
                    put(aAttrs[a].name, DateConversions.getDateFromIPSATime(lValue));
                } catch (NumberFormatException nfe) {
                  String sValue;
                  try { sValue = oAttr.toString(); } catch (Exception ignore) { sValue = ""; }
                  if (sValue.length()>0)
                    put(aAttrs[a].name, Attr.toDate(sValue));
                }
                break;
              default:
                Log.out.error("Unrecognized data type "+oAttr.dataType().name());
              }
            } else if (oAttr.count()>1) {
              switch (oAttr.dataType()) {
                case STRING:
                  String[] aStrs = new String[oAttr.count()];
                  for (int c=0; c<oAttr.count(); c++) aStrs[c] = oAttr.get(c).toString();
                  put(aAttrs[a].name, aStrs);
                  break;
                case NUMBER:
                  BigDecimal[] aDecs = new BigDecimal[oAttr.count()];
                  for (int c=0; c<oAttr.count(); c++) aDecs[c] = oAttr.get(c).toBigDecimal();
                  put(aAttrs[a].name, aDecs);
                  break;
                case DATE:
                  Date[] aDats = new Date[oAttr.count()];
                  for (int c=0; c<oAttr.count(); c++) aDats[c] = oAttr.get(c).toDate();
                  put(aAttrs[a].name, aDats);
                  break;
                case DATE_TIME:
                  Date[] aDttm = new Date[oAttr.count()];
                  for (int c=0; c<oAttr.count(); c++) {
                    long lValue;
                    try {
                      lValue = oAttr.toLong();
                      if (lValue!=-1l)       
                        aDttm[c] = DateConversions.getDateFromIPSATime(lValue);
                      else
                        aDttm[c] = null;
                    } catch (NumberFormatException nfe) {
                      String sValue;
                      try {
                        sValue = oAttr.toString();
                      } catch (Exception ignore) { sValue = ""; }                   
                      if (sValue.length()>0)       
                        aDttm[c] = Attr.toDate(sValue);
                      else
                        aDttm[c] = null;
                    }                   
                  }
                  put(aAttrs[a].name, aDttm);
                  break;
                default:
                  Log.out.error("Unrecognized data type "+oAttr.dataType().name());
                }             
            }
          } // fi
        } catch (Exception resumenext) {
          String sAttrValue = "";
          try { sAttrValue = oAttr.toString(); } catch (Exception ignore) { }
          System.out.println(resumenext.getClass().getName()+" "+(oAttr==null ? "" : sAttrValue)+" "+aAttrs[a].name+" "+resumenext.getMessage());
          Log.out.error(resumenext.getClass().getName()+" "+(oAttr==null ? "" : sAttrValue)+" "+aAttrs[a].name+" "+resumenext.getMessage());
        }
      } // next
    } // fi
View Full Code Here


          if (oAdm.isConnected()) oAdm.disconnect();
          if (oAdm.isOpen()) oAdm.close();         
        }       
      }
    } // fi
    AttributeMultiValue oAttr;
    Iterator<String> oKeys = keySet().iterator();
    while (oKeys.hasNext()) {
      String sKey = oKeys.next();
      Object oVal = get(sKey);
      if (oVal!=null) {
        if (oVal instanceof String) {
          oAttr = oDoc.attribute(sKey);
          oAttr.set((String) oVal);
        } else if (oVal instanceof Date) {
          oAttr = oDoc.attribute(sKey);
          if (oAttr.type().getDataType().equals(DataType.DATE))
            oAttr.set((Date) (oVal));
          else if (oAttr.type().getDataType().equals(DataType.DATE_TIME))
            oAttr.set((long) DateConversions.getIPSATimeFromDate((Date) (oVal)));
          else
            throw new ClassCastException("Cannot bind Java "+oVal.getClass().getName()+" into "+sKey+" "+oAttr.type().getDataType().name());
        } else if (oVal instanceof BigDecimal) {
          oAttr = oDoc.attribute(sKey);
          BigDecimal oDec = (BigDecimal) oVal;
          try {
            BigInteger oBig = oDec.toBigIntegerExact();
            oAttr.set(oBig.longValue());               
            } catch (ArithmeticException ex) {
            oAttr.set(oDec);
            }
        } else if (oVal instanceof Integer) {
          oAttr = oDoc.attribute(sKey);
          oAttr.set((long) ((Integer) oVal).intValue());
        } else if (oVal instanceof Long) {
          oAttr = oDoc.attribute(sKey);
          oAttr.set(((Long) oVal).longValue());
        } else if (oVal instanceof Float) {
          oAttr = oDoc.attribute(sKey);
          oAttr.set((double) ((Float) oVal).floatValue());
        } else if (oVal instanceof Double) {
          oAttr = oDoc.attribute(sKey);
          oAttr.set(((Double) oVal).doubleValue());
        } else if (oVal instanceof String[]) {
          String[] aStrs = (String[]) oVal;
          oAttr = oDoc.attribute(sKey);
          if (!oAttr.type().isMultivaluable()) throw new AttributeTypeHasValuesException("Cannot set multiple values for attribute "+sKey);
          int nVals = oAttr.count();
          for (int c=0; c<aStrs.length; c++) {
            if (c<nVals)
              oAttr.get(c).set(aStrs[c]);
            else
              oAttr.add().set(aStrs[c]);           
          } // next
        } else if (oVal instanceof BigDecimal[]) {
          oAttr = oDoc.attribute(sKey);
          if (!oAttr.type().isMultivaluable()) throw new AttributeTypeHasValuesException("Cannot set multiple values for attribute "+sKey);
          int nVals = oAttr.count();
          BigDecimal[] aDecs = (BigDecimal[]) oVal;
          for (int c=0; c<aDecs.length; c++) {
            try {
              BigInteger oBig = aDecs[c].toBigIntegerExact();
              if (c<nVals)
                oAttr.get(c).set(oBig.longValue());
              else
                oAttr.add().set(oBig.longValue());
            } catch (ArithmeticException ex) {
              if (c<nVals)
                oAttr.get(c).set(aDecs[c]);
              else
                oAttr.add().set(aDecs[c]);
            }
          } // next
        } else {
          throw new ClassCastException("Cannot bind Java "+oVal.getClass().getName()+" into "+sKey);
        }
View Full Code Here

    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("");
View Full Code Here

    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);
View Full Code Here

        }
        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");
View Full Code Here

    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);
          Log.out.debug("employee_uuid is empty "+e.isEmpty());
          if (!e.isEmpty()) Log.out.debug("employee_uuid is "+e.toString());
         
          c = new Concept(a.toString(), Attr.toDate(t.toString()));
          if (sEmployeeUuid==null) {
            if (!oSet.contains(c.getName())) {
              oCps.add(c);
              oSet.add(c.getName());
            }
          } else if (e.isEmpty()) {
            if (!oSet.contains(c.getName())) {
              oCps.add(c);
              oSet.add(c.getName());
           
          } else if (sEmployeeUuid.equals(e.toString())) {
            if (!oSet.contains(c.getName())) {
              oCps.add(c);
              oSet.add(c.getName());
            }           
          }
View Full Code Here

TOP

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

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.