Package it.eng.spagobi.kpi.model.dao

Examples of it.eng.spagobi.kpi.model.dao.IResourceDAO


      // load resource

      if (modRes.getResourceId() != null) {
        Integer resId=modRes.getResourceId();
        IResourceDAO resDAO=DAOFactory.getResourceDAO();
        Resource res=resDAO.loadResourceById(resId);

        insertResource(res, session);
        SbiResources sbiRes= (SbiResources) session.load(SbiResources.class, res.getId());
        if(sbiRes!=null){
          hibModRes.setSbiResources(sbiRes);
View Full Code Here


            "Exception occurred while deleting contact",
            e);
      }
    }else if(serviceType == null){
      try {
        IResourceDAO resourceDao = DAOFactory.getResourceDAO();
        List<String> resources = (List<String>)getSessionContainer().getAttribute(RESOURCES_LIST);
        if(resources == null){
          List<Resource> resourcesOBJ = resourceDao.loadResourcesList(null, null);
          resources = new ArrayList<String>();
          for(int i =0; i< resourcesOBJ.size(); i++){
            Resource res = resourcesOBJ.get(i);
            resources.add(res.getName());
          }
View Full Code Here

              : "Kpi Instance ID null"));
      SbiKpiInstance sbiKpiInstance = (SbiKpiInstance) aSession.load(
          SbiKpiInstance.class, kpiInstanceId);
      Resource r = value.getR();
      if (r != null) {
        IResourceDAO resDaoImpl=DAOFactory.getResourceDAO();
        SbiResources sbiResources = resDaoImpl.toSbiResource(r);
        logger.debug("Resource: "
            + (r.getName() != null ? r.getName()
                : "Resource name null"));
        hibKpiValue.setSbiResources(sbiResources);
      }
View Full Code Here

    String scaleCode = null;
    String scaleName = null;

    SbiResources res = value.getSbiResources();
    Resource r = null;
    IResourceDAO resDao=DAOFactory.getResourceDAO();
    if (res != null) {
      r = resDao.toResource(res);
      logger.debug("SbiKpiValue resource: "
          + (r.getColumn_name() != null ? r.getColumn_name()
              : "resource name null"));
    }
View Full Code Here

    String scaleCode = null;
    String scaleName = null;

    SbiResources res = value.getSbiResources();
    Resource r = null;
    IResourceDAO resDao=DAOFactory.getResourceDAO();
    if (res != null) {
      r = resDao.toResource(res);
      logger.debug("SbiKpiValue resource: "
          + (r.getColumn_name() != null ? r.getColumn_name() : "resource name null"));
    }
    SbiOrgUnit sbiOrgUnit = value.getSbiOrgUnit();
    OrganizationalUnit orgUnit = null;
View Full Code Here

  public static Integer LIMIT_DEFAULT = 15;

  @Override
  public void doService() {
    logger.debug("IN");
    IResourceDAO resDao;
    try {
      resDao = DAOFactory.getResourceDAO();
      resDao.setUserProfile(getUserProfile());
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    Locale locale = getLocale();

    String serviceType = this.getAttributeAsString(MESSAGE_DET);
    logger.debug("Service type "+serviceType);
    if (serviceType != null && serviceType.equalsIgnoreCase(RESOURCES_LIST)) {
     
      try {   
       
        Integer start = getAttributeAsInteger( START );
        Integer limit = getAttributeAsInteger( LIMIT );
       
        if(start==null){
          start = START_DEFAULT;
        }
        if(limit==null){
          limit = LIMIT_DEFAULT;
        }

        Integer totalResNum = resDao.countResources();
        List resources = resDao.loadPagedResourcesList(start,limit);
        logger.debug("Loaded resources list");
        JSONArray resourcesJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(resources, locale);
        JSONObject resourcesResponseJSON = createJSONResponseResources(resourcesJSON, totalResNum);

        writeBackToClient(new JSONSuccess(resourcesResponseJSON));

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving users", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving users", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(RESOURCE_INSERT)) {
      String id = getAttributeAsString(ID);
      String code = getAttributeAsString(CODE);
      String name = getAttributeAsString(NAME);
      String description = getAttributeAsString(DESCRIPTION);
      String tablename = getAttributeAsString(TABLE_NAME);
      String columnname = getAttributeAsString(COLUMN_NAME);
      String resourceTypeCD = getAttributeAsString(NODE_TYPE_CODE);   
     
      List<Domain> domains = (List<Domain>)getSessionContainer().getAttribute("nodeTypesList");
     
        HashMap<String, Integer> domainIds = new HashMap<String, Integer> ();
        if(domains != null){
          for(int i=0; i< domains.size(); i++){
            domainIds.put(domains.get(i).getValueCd(), domains.get(i).getValueId());
          }
        }
       
        Integer resourceTypeID = domainIds.get(resourceTypeCD);
        if(resourceTypeID == null){
          logger.error("Resource type CD does not exist");
          throw new SpagoBIServiceException(SERVICE_NAME,  "Resource Type ID is undefined");
        }

      if (name != null && resourceTypeID != null && code != null) {
        Resource res = new Resource();
        res.setName(name);
        res.setType(resourceTypeCD);
        res.setTypeId(resourceTypeID);
        res.setCode(code);
       
        if(description != null){
          res.setDescr(description);
       
        if(tablename != null){
          res.setTable_name(tablename);
        }
        if(columnname != null){
          res.setColumn_name(columnname);
        }       
       
        try {
          if(id != null && !id.equals("") && !id.equals("0")){             
            res.setId(Integer.valueOf(id));
            resDao.modifyResource(res);
            logger.debug("Resource "+id+" updated");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", id);
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }else{
            Integer resourceID = resDao.insertResource(res);
            logger.debug("New Resource inserted");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", resourceID);
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }

        } catch (Throwable e) {
          logger.error(e.getMessage(), e);
          throw new SpagoBIServiceException(SERVICE_NAME,
              "Exception occurred while saving new resource", e);
        }
               
      }else{
        logger.error("Resource name, code or type are missing");
        throw new SpagoBIServiceException(SERVICE_NAME,  "Please fill resource name, code and type");
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(RESOURCE_DELETE)) {
      Integer id = getAttributeAsInteger(ID);
      try {
        resDao.deleteResource(id);
        logger.debug("Resource deleted");
        writeBackToClient( new JSONAcknowledge("Operation succeded") );
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving resource to delete", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
View Full Code Here

TOP

Related Classes of it.eng.spagobi.kpi.model.dao.IResourceDAO

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.