Package com.vst.service.impl

Source Code of com.vst.service.impl.BuildingObjectManagerImpl

package com.vst.service.impl;

import com.vst.dao.BuildingObjectDao;
import com.vst.dao.ConstructionExampleDao;
import com.vst.dao.ObjectAnswerDao;
import com.vst.model.BuildingObject;
import com.vst.model.ConstructionExample;
import com.vst.model.DangerCategory;
import com.vst.model.ObjectAnswer;
import com.vst.model.ObjectPhoto;
import com.vst.service.BuildingObjectManager;
import com.vst.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.io.IOException;
import java.sql.SQLException;

import org.apache.commons.dbcp.BasicDataSource;

public class BuildingObjectManagerImpl extends BaseManager implements BuildingObjectManager {
    private BuildingObjectDao dao;
    private ObjectAnswerDao objectAnswerDao;
    private ConstructionExampleDao constructionExampleDao;

    public void setConstructionExampleDao(ConstructionExampleDao constructionExampleDao) {
        this.constructionExampleDao = constructionExampleDao;
    }

    public void setObjectAnswerDao(ObjectAnswerDao objectAnswerDao) {
        this.objectAnswerDao = objectAnswerDao;
    }

    /**
     * Set the Dao for communication with the data layer.
     *
     * @param dao
     */
    public void setBuildingObjectDao(BuildingObjectDao dao) {
        this.dao = dao;
    }

    /**
     * @see com.vst.service.BuildingObjectManager#getBuildingObjects(com.vst.model.BuildingObject)
     */
    public List getBuildingObjects(final BuildingObject buildingObject) {
        return dao.getBuildingObjects(buildingObject);
    }

    public List getBuildingObjectsForTree() {
         return dao.getBuildingObjectsForTree();
    }

    public List findBuildingObjectsByName(BuildingObject buildingObject) {
        return dao.findBuildingObjectsByName(buildingObject);
    }


    public List getBuildingObjectsForList(){
        return dao.getBuildingObjectsForList();
    }

  public BuildingObject getBuildingObjectForList(Integer objectId) {
    return dao.getBuildingObjectForList(objectId);
  }

    public List fillQuestionsLists(List buildingObjects) {
        for (int i = 0; i < buildingObjects.size(); i++) {
            BuildingObject buildingObject = (BuildingObject) buildingObjects.get(i);
            buildingObject.setDocQuestions(dao.getDocAnswers(buildingObject.getObjectId().toString()));
            buildingObject.setObjectQuestions(dao.getObjectAnswersAnswers(buildingObject.getObjectId().toString()));
        }
        return buildingObjects;
    }

    public DangerCategory getConstructionRecommendedDangerCategory(String buildingObjectId) {
        return dao.getConstructionRecommendedDangerCategory(buildingObjectId);
    }

    public List getObjectConstructionsByTypeId(String buildingObjectId, String typeId) {
        return dao.getObjectConstructionsByTypeId(buildingObjectId, typeId);
    }

    public Integer getObjectConstructionTypeExampleByCategory(String objectId, String typeId, String dangerCategoryName) {
        return dao.getObjectConstructionTypeExampleByCategory(objectId, typeId, dangerCategoryName);
    }

    public List getAnswersByDocumentation(String objectId, String type) {
        return dao.getAnswersByDocumentation(objectId, type);
    }

    public Integer getObjectConstructionTypeExampleNum(String objectId, String typeId) {
        return dao.getObjectConstructionTypeExampleNum(objectId, typeId);
    }

    public List getObjectGroupedConstructionTypes(String ojectId) {
        return dao.getObjectGroupedConstructionTypes(ojectId);
    }

    public ObjectAnswer getNextQestion(Integer objectId, Integer questionId, boolean forObject) {
        return objectAnswerDao.getNextQestion(objectId, questionId, forObject);
    }

    public ObjectAnswer getPrevQestion(Integer objectId, Integer questionId, boolean forObject) {
        return objectAnswerDao.getPrevQestion(objectId, questionId, forObject);
    }

    public List getDocumentationQuestions() {
        return dao.getDocumentationQuestions();
    }

    public void makeNotNull(BuildingObject buildingObject) {
        dao.evict(buildingObject);
        if (buildingObject.getDangerCategory() == null) {

            buildingObject.setDangerCategory(new DangerCategory());
        }
    }

    /**
     * @see com.vst.service.BuildingObjectManager#getBuildingObject(String objectId)
     */
    public BuildingObject getBuildingObject(final String objectId) {
        return dao.getBuildingObject(new Integer(objectId));
    }

    public BuildingObject getBuildingObjectForBreadCrump(final String objectId){
        return dao.getBuildingObjectForBreadCrump(objectId);
    }

    /**
     * @see com.vst.service.BuildingObjectManager#saveBuildingObject(BuildingObject buildingObject)
     */
    public void saveBuildingObject(BuildingObject buildingObject) {
//        buildingObject.setObjectType(objectTypeDao.getObjectType(buildingObject.getObjectType().getObjectTypeId()));
        dao.saveBuildingObject(buildingObject);
    }

    /**
     * @see com.vst.service.BuildingObjectManager#removeBuildingObject(String objectId)
     */
    public boolean removeBuildingObject(final String objectId) {
        dao.removeBuildingObject(new Integer(objectId));
        return true;
    }


    public List getConstructionTypesForTree(BuildingObject buildingObject) {
        return dao.getConstructionTypesForTree(buildingObject.getObjectId());
    }

    public boolean haveNecessaryQuestionsWithOutAnswers(Integer buildingObjectId, String currentPath) throws IOException, SQLException {
        BasicDataSource basicDataSource= (BasicDataSource) BeanUtils.getBean("dataSource",currentPath);
                 Properties props = new Properties();
                 props.setProperty("driver.url", "jdbc:mysql://localhost/vstbase");
                 props.setProperty("driver.class",basicDataSource.getDriverClassName());
                 props.setProperty("user",basicDataSource.getUsername());
                 props.setProperty("password",basicDataSource.getPassword());

        return dao.haveNecessaryQuestionsWithOutAnswers(buildingObjectId,props);
    }

  public List<ObjectPhoto> getObjectPhotoes(Integer objectId) {
    return dao.getObjectPhotoes(objectId);
  }

  public void updateBuildingObjectByMainForm(Integer objectId,
      BuildingObject formObject) {
    dao.updateBuildingObjectByMainForm(objectId, formObject);
  }

  public void savePreparedDocumentationQuestions(Integer objectId) {
    dao.savePreparedDocumentationQuestions(objectId);
  }

}
TOP

Related Classes of com.vst.service.impl.BuildingObjectManagerImpl

TOP
Copyright © 2018 www.massapi.com. 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.