Package com.exedosoft.plat.bo

Examples of com.exedosoft.plat.bo.DOService


    // 处理登录

    String echoStr = "";
    String returnUrl = "";

    DOService aService = DOService
        .getService("multi_tenancy_browse_byname");
    // ////////////根据用户查找租户
    BOInstance tenant = aService.getInstance(formBI.getValue("tenancyId"));
    // ////////如果租户不存在
    if (tenant == null || tenant.getName() == null) {
      ret[0] = I18n.instance().get("该账号没有被激活!");
      return ret;
    }
    log.info("当前登录的租户为::" + formBI.getValue("tenancyId"));

    // tenant data datastore url
    String multi_datasource_uid = tenant.getValue("multi_datasource_uid");
    // tenant config datastore url
    String model_datasource_uid = tenant.getValue("model_datasource_uid");

    DODataSource dataDds = dsConfig.get(multi_datasource_uid);
    DODataSource dds = dsConfig.get(model_datasource_uid);

    if (dataDds == null && dds == null) {

      DOService findDataSource = DOService
          .getService("multi_datasource_browse");

      // //data datasource
      BOInstance aBI = findDataSource.getInstance(multi_datasource_uid);
      if (aBI != null) {
        dataDds = (DODataSource) aBI.toObject(DODataSource.class);
        // /现在多租户情况下默认都是mysql
        dataDds.setDialect(DODataSource.DIALECT_MYSQL);
        dsConfig.put(multi_datasource_uid, dataDds);
      }

      // /model datasource
      aBI = findDataSource.getInstance(model_datasource_uid);
      if (aBI != null) {
        dds = (DODataSource) aBI.toObject(DODataSource.class);
        // /现在多租户情况下默认都是mysql
        dds.setDialect(DODataSource.DIALECT_MYSQL);
        dsConfig.put(model_datasource_uid, dds);
      }
    }

    if (dataDds == null || dds == null) {
      ret[0] = I18n.instance().get("该账号没有被激活或者没有正确初始化,请与管理员联系!");
      return ret;
    }

    // /globals 放到session中

    // //需要更改多租户表中,租户数据库中的数据源
    // ////每个租户为定位到某个物理数据库中
    // ///租户数据库分配
    TenancyValues tv = new TenancyValues(dds, tenant);

    tv.setDataDDS(dataDds);
    DOGlobals.getInstance().getSessoinContext().setTenancyValues(tv);

    /**
     * 查找账号
     */
    MultiAccount ma = MultiAccount.findAccount(formBI.getValue("name"),
        formBI.getValue("password"), formBI.getValue("tenancyId"));
    BOInstance user = new BOInstance();
   

    if (ma == null) {
      // //////////直接可以从用户表中访问,可以考虑,计费时根据这个表计费,肯定还需要一个计费表和这个表关联。另外一个思路是同意注册。

      String serviceName = request.getParameter("contextServiceName");
      BOInstance biUser = null;
      if (serviceName != null && !serviceName.trim().equals("")) {
        DOService findUserByUserNamePassword = DOService
            .getService(serviceName);
        List listUser = findUserByUserNamePassword.invokeSelect();
        if (listUser != null && listUser.size() > 0) {
          biUser = (BOInstance) listUser.get(0);
        }

      }
      if (biUser == null) {
        ret[0] = I18n.instance().get("账号/密码出错,请重试!");
        return ret;
      } else {
        user = biUser;
        // /设置公司名称
        user.putValue("company", tenant.getValue("l10n"));
      }

    } else {

      user.fromObject(ma);
      DOService findUserService = DOService
          .getService("do_org_user_browse");

      List corrUsers = findUserService.invokeSelect(ma.getObjUid());
      BOInstance employee = null;
      try {
        if (corrUsers == null || corrUsers.size() == 0) {
          // user.putValue("objuid",
          // ma.getObjUid());
          DOService storeUser = DOService
              .getService("do_org_user_insert");
          // /建立用户间的对应关系
          user.putValue("user_code", user.getValue("name"));
          employee = storeUser.store(user);

        } else {
          employee = (BOInstance) corrUsers.get(0);
        }
      } catch (ExedoException e) {
View Full Code Here


  }

  public static void main(String[] args) {

    CacheFactory.getCacheData().fromSerialObject();
    DOService findDataSource = DOService
        .getService("multi_datasource_browse");

    // //data datasource
    BOInstance aBI = findDataSource
        .getInstance("402881eb38a231d20138a23b4ab70015");
    DODataSource dataDds = null;
    if (aBI != null) {
      dataDds = (DODataSource) aBI.toObject(DODataSource.class);
      // /现在多租户情况下默认都是mysql
      dataDds.setDialect(DODataSource.DIALECT_MYSQL);
    }

    BOInstance aBI2 = findDataSource
        .getInstance("402881eb38a231d20138a23b4ab70015");
    DODataSource dataDds2 = null;
    if (aBI2 != null) {
      dataDds2 = (DODataSource) aBI2.toObject(DODataSource.class);
      // /现在多租户情况下默认都是mysql
View Full Code Here

    return DEFAULT_FORWARD;
  }
 
  public static void main(String[] args){
   
    DOService aService = DOService.getService("zf_employee_list_ldapbyaction");
   
    List list = aService.invokeSelect();
   
    BOInstance anItem = (BOInstance)list.get(5);
   
   
    System.out.println("An item::" + anItem);
View Full Code Here

    }

    /*
     * 必须定义两个服务,新增的服务和修改 的服务
     */
    DOService insertService = aFm.getLinkService();
    DOService updateService = aFm.getSecondService();

    if (insertService == null || updateService == null) {
      setEchoValue(I18n.instance().get("必须定义两个服务,新增的服务和修改的服务!"));
      return NO_FORWARD;
    }

    Connection con = null;
    int batchSize = 0;
    try {

      con = insertService.getBo().getDataBase().getContextConnection();
       // ////////////////////////////////////新增
      String inputName = uiForm.getValue("inputName");
      if (inputName != null && !inputName.trim().equals("")) {
        String[] inputValues = uiForm.getValueArray(inputName);
        log.info("Current SQL:" + insertService.getTempSql());
        PreparedStatement pstmt = con.prepareStatement(insertService
            .getTempSql());

        List<String> newIds = new ArrayList<String>();
        for (int len = 0; len < inputValues.length; len++) {
          int i = 1;
          for (Iterator it = insertService.retrieveParaServiceLinks()
              .iterator(); it.hasNext();) {
            DOParameterService dops = (DOParameterService) it
                .next();
            DOParameter dop = dops.getDop();

            String value = null;

            if (dop.getType() != null
                && dop.getType().intValue() == DOParameter.TYPE_FORM
                && dop.getDefaultValue() == null) {// //form类型直接从节目获取
              log.info("Batch Parameter Name:::" + dop.getName());
              String[] valueArray = uiForm.getValueArray(dop
                  .getName());
              value = valueArray[len];
              if ("".equals(value)) {
                value = null;
              }
            } else {
              value = dop.getValue();
            }
           
            if (dop.getType() != null
                && dop.getType().intValue() == DOParameter.TYPE_KEY) {
              newIds.add(value);
            }
            value = dops.getAfterPattermValue(value);
            insertService.putStatementAValue(pstmt, i, dops, value);
            i++;
          }
          batchSize++;
          pstmt.addBatch();
        }
        log.info("::batchSize:::" + batchSize);
        pstmt.executeBatch();
       
        /////多租户的处理
        for(String anID : newIds){
          insertService.dealMultiTenancy(null, con, anID);
        }
      }
      // ////////////////////////////////////end 新增=====================

      // ////////////修改   begin==============================================
      DOBO refreshBO = aFm.getGridModel().getService().getBo();

      String[] ids = uiForm.getValueArray("id");
      if (ids != null && ids.length > 0) {

        PreparedStatement pstmt = con.prepareStatement(updateService
            .getTempSql());
        for (int ii = 0; ii < ids.length; ii++) {
          String idstr = ids[ii];
          System.out.println("one isstr::" + idstr);
          if (idstr != null) {
            String[] vals = idstr.split(";﹕#");
            HashMap<String, String> paras = new HashMap<String, String>();
            String id = "";
            if (vals != null && vals.length > 0) {
              id = vals[0];
              for (int j = 1; j < vals.length; j++) {
                String aKeyValue = vals[j];
                System.out.println("aKeyValue::::::" + aKeyValue);
                String[] arrayKV = aKeyValue.split("﹕﹕");
                String aValue = null;
                if(arrayKV.length > 1){
                   aValue = arrayKV[1];
                }
                paras.put(arrayKV[0],aValue);
              }
            }
           
            System.out.println("paras:::::" + paras);

            BOInstance oldInstance = refreshBO.refreshContext(id);
            String newKeyValue = null;
            int i = 1;
            for (Iterator it = updateService
                .retrieveParaServiceLinks().iterator(); it
                .hasNext();) {
              DOParameterService dops = (DOParameterService) it
                  .next();
              DOParameter dop = dops.getDop();
              String value = null;
              if (dop.getType() != null
                  && dop.getType().intValue() == DOParameter.TYPE_FORM
                  && dop.getDefaultValue() == null) {
                log.info("批量修改参数的名称:::" + dop.getName());
                value = paras.get(dop.getName());
                if ("".equals(value)) {
                  value = null;
                }
              } else {
                value = dop.getValue();
              }

              if (dop.getType() != null
                  && dop.getType().intValue() == DOParameter.TYPE_KEY) {
                newKeyValue = value;
              }
              value = dops.getAfterPattermValue(value);
              updateService.putStatementAValue(pstmt, i, dops,
                  value);
              i++;
            }
            batchSize++;
            if (oldInstance != null) {
              CoreSaveAllAction.logOperation(updateService,
                  oldInstance, newKeyValue);
            }
            pstmt.addBatch();
          }
          log.info("批量修改::batchSize:::" + batchSize);
          pstmt.executeBatch();
        }
      }

    } catch (SQLException ex1) {
      ex1.printStackTrace();
      this.setEchoValue(ex1.getMessage());
      return NO_FORWARD;
    } finally {
      updateService.clearCache();
      try {
        insertService.getBo().getDataBase().ifCloseConnection(con);
      } catch (SQLException ex1) {
        ex1.printStackTrace();
        this.setEchoValue(ex1.getMessage());
View Full Code Here

    // TODO Auto-generated method stub
    // ///////给定一个服务
    // //////////给给一个需要保留的parameter列表
    // /////////修改这个服务的sql语句
    // ////////////删除不需要的参数关联
    DOService aService = DOService.getService("db.perambulate.item.insert");
    String leftParas = "OBJUID,NA_ITEM_NAME,NA_APPLY_PERSON,NA_PERAMBULATE_COMP,ID_QUALIFICATION_CARD,NA_COMP_ADDRESS,QT_PERAMBULATE_MINE,IN_PERAMBULATE_PHASE,IN_ITEM_KIND,IN_ECONOMY_TYPE,NA_GEOGRAPHY_POSITION,NA_AREA_COORDINATE,QT_BASIC_SECTION,QT_QTRBASIC_SECTION,QT_SMALL_SECTION,QT_CONVERTBASIC_SECTION,QT_TOTAL_AREA,QT_LONGEAST_START,QT_LONGEAST_END,QT_LATNORTH_START,QT_LATNORTH_END,IN_PROSPECT_KIND,QT_COST,IN_ITEM_TYPE,ID_LICENCEID,approve_org,approve_org_code";
    String theSql = aService.getMainSql().toLowerCase();
    System.out.println("Orign SQL:" + theSql);
    String[] paras = leftParas.split(",");
    List dops = aService.retrieveParaServiceLinks();
//    HbmDAO dao = new HbmDAO();
//    dao.setAutoClose(false);
    try {

      for (Iterator it = dops.iterator(); it.hasNext();) {
        DOParameterService aDop = (DOParameterService) it.next();
        boolean isLeft = false;
        for (int i = 0; i < paras.length; i++) {
          if (aDop.getDop().getName().equalsIgnoreCase(paras[i])) {
            isLeft = true;
            break;
          }
        }
        if (!isLeft) {
          String aPara = aDop.getDop().getName().toLowerCase() + ",";
          theSql = theSql.replaceAll(aPara, "");
          theSql = theSql.replaceAll("(\\,\\?\\))", ")");
          DAOUtil.INSTANCE().delete(aDop);
        }
      }
      aService.setMainSql(theSql);
      DAOUtil.INSTANCE().store(aService);
    }
    catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

      /**
       * 根据Service生成ui组件。
       */
      for (Iterator itServ = sers.iterator(); itServ.hasNext();) {

        DOService aService = (DOService) itServ.next();

        if (aService.getName().endsWith("browse")) {
          genePaneAndGrid( aService, gridBrowse, "");
          genePaneAndGrid( aService, gridUpdate, ".update");
        } else if (aService.getName().endsWith("insert")) {
          continue;
        } else if (aService.getName().endsWith("update")) {
          continue;
        } else if (aService.getName().endsWith("list")) {
          genePaneAndGrid( aService, gridList, "");
          genePaneAndGrid( aService, gridInsert, ".insert");
        }
      }

View Full Code Here

    // ///装电话小灵通, 83747268
    // //装电话公司电话, 61758100

    DOFormModel formM = new DOFormModel();
    formM.setL10n("保存");
    DOService linkService = DOService.getService(aService.getBo().getName()
        + aName);
    formM.setLinkService(linkService);
    formM.setIsNewLine(1);
    formM.setNameColspan(Integer.valueOf(0));
    formM.setIsOutGridAction(DOFormModel.OUTGRID_BOTTOM);
View Full Code Here

   */

  private void appendRoles(List allAuths, String accountUid, OrgParter parter) {

    if (parter.isRole()) {
      DOService findUserService = DOService
          .getService("do.bx.role.findbyuseridcontext");
      List listRoles = findUserService.invokeSelect(accountUid);
      if (listRoles != null) {
        for (Iterator roles = listRoles.iterator(); roles.hasNext();) {
          BOInstance boRole = (BOInstance) roles.next();
          OrgParterValue pv = new OrgParterValue(parter, boRole
              .getUid(), boRole.getName());
View Full Code Here

  public List getMenuAuthConfigByAccount(String accountUid) {

    // //////////先获取角色菜单的权限

    List pureMenuUids = new ArrayList();
    DOService rfService = DOService
        .getService("do.bx.role.findbyuserid.xes.ids_xes");
    List rfList = rfService.invokeSelect(accountUid);

    for (Iterator it = rfList.iterator(); it.hasNext();) {
      BOInstance bi = (BOInstance) it.next();
      pureMenuUids.add(bi.getValue("whatuid"));
    }
View Full Code Here

    // } catch (Exception e1) {
    // // TODO Auto-generated catch block
    // // e1.printStackTrace();
    // }

    DOService updateService = DOService
        .getService("do_log_update_by_sessionid");

    if (updateService != null) {
      try {
        BOInstance aInstance = new BOInstance();
        aInstance.putValue("logoffTime", new Timestamp(System
            .currentTimeMillis()));
        aInstance.putValue("sessionid", se.getSession().getId());
        updateService.invokeUpdate(aInstance);
        // aInstance.invokeUpdate();
      } catch (ExedoException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
View Full Code Here

TOP

Related Classes of com.exedosoft.plat.bo.DOService

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.