Package com.vst.dao.util

Source Code of com.vst.dao.util.RefferenceUtil

package com.vst.dao.util;

import com.vst.dao.BuildingObjectDao;
import com.vst.dao.ConstructionDefectDao;
import com.vst.dao.ConstructionExampleDao;
import com.vst.dao.ObjectConstructionDao;
import com.vst.model.*;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.BeansException;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.FileNotFoundException;
import java.util.List;

/**
* Created by IntelliJ IDEA.
* User: ALEXEI
* Date: 05.07.2008
* Time: 15:16:28
* To change this template use File | Settings | File Templates.
*/
public class RefferenceUtil {

    public static void makeURL(List referenceList, String objectType, List objectList) {
        BeanFactory factory = null;
        try {
            Resource res = new ClassPathResource("../applicationContext-hibernate.xml");
            factory = new XmlBeanFactory(res);
        } catch (BeansException e) {

        }

        if (objectType.equals("buildingObject")) {
            for (int i = 0; i < objectList.size(); i++) {
                BuildingObject buildingObject = (BuildingObject) objectList.get(i);
                referenceList.add("<a href='buildingObjects.html?objectId=" + buildingObject.getObjectId() + "'>Объект обследования - " + buildingObject.getName() + "</a><br/>");
            }
        }

        if (objectType.equals("defectType")) {
            for (int i = 0; i < objectList.size(); i++) {
                DefectType defectType = (DefectType) objectList.get(i);
                referenceList.add("<a href='defectTypes.html?defectTypeId=" + defectType.getDefectTypeId() + "'>Тип дефекта - " + defectType.getDefectTypeName() + "</a><br/>");
            }
        }


        if (objectType.equals("objectConstruction")) {

            for (int i = 0; i < objectList.size(); i++) {
                ObjectConstruction objectConstruction = (ObjectConstruction) objectList.get(i);
                referenceList.add("<a href='objectConstructions.html?typeId=" + objectConstruction.getTypeId() + "&objectId=" + objectConstruction.getObjectId() + "'>Вид конструкции - " + objectConstruction.getConstructionType() + ((objectConstruction.getDescription() != null && !objectConstruction.getDescription().trim().equals("")) ? " - " + objectConstruction.getDescription() : "") + "</a><br/>");
                //System.out.println("objectConstruction");
                //System.out.println("<a href='objectConstructions.html?typeId=" + objectConstruction.getTypeId() + "&objectId=" + objectConstruction.getObjectId() + "'>Вид конструкции - " + objectConstruction.getConstructionType() + ((objectConstruction.getDescription() != null && !objectConstruction.getDescription().trim().equals("")) ? " - " + objectConstruction.getDescription() : "") + "</a><br/>");

            }
        }

        if (objectType.equals("constructionDefect")) {
            for (int i = 0; i < objectList.size(); i++) {
                ConstructionDefect constructionDefect = (ConstructionDefect) objectList.get(i);
                referenceList.add("<a href='constructionDefects.html?constructionDefectId=" + constructionDefect.getConstructionDefectId() + "&exampleId=" + constructionDefect.getExampleId() + "'>Дефект экземпляра - " + constructionDefect.getDefectNumber() + " - " + constructionDefect.getDefectType() + "</a><br/>");
            }
        }

        if (objectType.equals("constructionExample")) {
            for (int i = 0; i < objectList.size(); i++) {
                ConstructionExample constructionExample = (ConstructionExample) objectList.get(i);
                referenceList.add("<a href='constructionExamples.html?exampleId=" + constructionExample.getExampleId() + "&typeId=" + constructionExample.getObjectConstructionId() + "'>Экземпляр контрукции - " + ((constructionExample.getExampleName() == null || constructionExample.getExampleName().trim().equals("")) ? String.valueOf(constructionExample.getExampleRelativeNumber()) : constructionExample.getExampleName()) + "</a><br/>");
            }
        }

        if (objectType.equals("defectRecomendation")) {

            for (int i = 0; i < objectList.size(); i++) {
                DefectRecomendation defectRecomendation = (DefectRecomendation) objectList.get(i);
                referenceList.add("<a href='defectRecomendations.html?defectRecomendationId=" + defectRecomendation.getDefectRecomendationId() + "'>Рекомендация по устранению дефекта - " + defectRecomendation.getContent() + "</a><br/>");
                //System.out.println("defectRecomendation");
                //System.out.println("<a href='defectRecomendations.html?defectRecomendationId=" + defectRecomendation.getDefectRecomendationId() + "'>Рекомендация по устранению дефекта - " + defectRecomendation.getContent() + "</a><br/>");
            }
        }

        if (objectType.equals("question")) {

            for (int i = 0; i < objectList.size(); i++) {
                Question question = (Question) objectList.get(i);
                referenceList.add("<a href='questions.html?questionId=" + question.getQuestionId() + "'>Вопрос - " + question.getContents() + "</a><br/>");
                //System.out.println("question");
                //System.out.println("<a href='questions.html?questionId=" + question.getQuestionId() + "'>Вопрос - " + question.getContents() + "</a><br/>");
            }
        }

        if (objectType.equals("reason")) {

            for (int i = 0; i < objectList.size(); i++) {
                Reason reason = (Reason) objectList.get(i);
                referenceList.add("<a href='reasons.html?reasonId=" + reason.getReasonId() + "'>Причина дефекта - " + reason.getReasonName() + "</a><br/>");
                //System.out.println("reason");
                //System.out.println("<a href='reasons.html?reasonId=" + reason.getReasonId() + "'>Причина дефекта - " + reason.getReasonName() + "</a><br/>");
            }
        }

        if (objectType.equals("defectCategory")) {

            for (int i = 0; i < objectList.size(); i++) {
                DefectCategory defectCategory = (DefectCategory) objectList.get(i);
                referenceList.add("<a href='defectCategorys.html?defectCategoryId=" + defectCategory.getDefectCategoryId() + "'>Категория дефекта - " + defectCategory.getDefectCategoryFullCaption() + "</a><br/>");
                //System.out.println("<a href='defectCategorys.html?defectCategoryId=" + defectCategory.getDefectCategoryId() + "'>Категория дефекта - " + defectCategory.getDefectCategoryFullCaption() + "</a><br/>");
            }
        }

        if (objectType.equals("materialClassification")) {

            for (int i = 0; i < objectList.size(); i++) {
                MaterialClassification materialClassification = (MaterialClassification) objectList.get(i);
                referenceList.add("<a href='materialClassifications.html?materialClassificationId=" + materialClassification.getMaterialClassificationId() + "'>Классификация материала - " + materialClassification.getMaterialClassificationName() + "</a><br/>");
                //System.out.println("<a href='materialClassifications.html?materialClassificationId=" + materialClassification.getMaterialClassificationId() + "'>Классификация материала - " + materialClassification.getMaterialClassificationName() + "</a><br/>");
            }
        }

        if (objectType.equals("parameter")) {

            for (int i = 0; i < objectList.size(); i++) {
                Parameter parameter = (Parameter) objectList.get(i);
                referenceList.add("<a href='parameters.html?parameterId=" + parameter.getParameterId() + "'>Классификация материала - " + parameter.getParameterName() + "</a><br/>");
                //System.out.println("<a href='parameters.html?parameterId=" + parameter.getParameterId() + "'>Классификация материала - " + parameter.getParameterName() + "</a><br/>");
            }
        }

        if (objectType.equals("defectParameter")) {

            for (int i = 0; i < objectList.size(); i++) {
                DefectParameter defectParameter = (DefectParameter) objectList.get(i);
                Integer constructionDefectId = defectParameter.getConstructionDefectId();
                try {
                    ConstructionDefectDao constructionDefectDao = (ConstructionDefectDao) factory.getBean("constructionDefectDao");
                    ConstructionDefect constructionDefect = (ConstructionDefect) constructionDefectDao.getConstructionDefect(constructionDefectId);
                    ConstructionExampleDao constructionExampleDao = (ConstructionExampleDao) factory.getBean("constructionExampleDao");
                    ConstructionExample constructionExample = constructionExampleDao.getConstructionExample(constructionDefect.getExampleId());
                    referenceList.add("<a href='constructionDefects.html?constructionDefectId=" + defectParameter.getConstructionDefectId() + "&exampleId=" + constructionDefect.getExampleId() + "'>Параметр дефекта экземпляра конструкции - " + (constructionExample.getExampleName() == null ? String.valueOf(constructionExample.getExampleRelativeNumber()) : constructionExample.getExampleName()) + ". Тип конструкции - " + constructionExample.getConstructionType() + "</a><br/>");
                    //System.out.println("<a href='constructionDefects.html?constructionDefectId=" + defectParameter.getConstructionDefectId() + "&exampleId=" + constructionDefect.getExampleId() + "'>Параметр дефекта экземпляра конструкции - " + (constructionExample.getExampleName() == null ? constructionExample.getExampleNumber() : constructionExample.getExampleName()) + ". Тип конструкции - " + constructionExample.getConstructionType() + "</a><br/>");
                }
                catch (Exception e) {

                    e.printStackTrace();
                }
            }
        }

        if (objectType.equals("defectVarity")) {

            for (int i = 0; i < objectList.size(); i++) {
                DefectVarity defectVarity = (DefectVarity) objectList.get(i);
                referenceList.add("<a href='defectVaritys.html?varityId=" + defectVarity.getVarityId() + "'>Характер дефекта - " + defectVarity.getVarityName() + "</a><br/>");
                //System.out.println("<a href='defectVaritys.html?varityId=" + defectVarity.getVarityId() + "'>Характер дефекта - " + defectVarity.getVarityName() + "</a><br/>");
            }
        }

        if (objectType.equals("hint")) {

            for (int i = 0; i < objectList.size(); i++) {
                Hint hint = (Hint) objectList.get(i);
                referenceList.add("<a href='hints.html?hintId=" + hint.getHintId() + "'>Подсказка к вопросу - " + hint.getContents() + "</a><br/>");
            }
        }


        if (objectType.equals("objectAnswer")) {

            for (int i = 0; i < objectList.size(); i++) {
                ObjectAnswer objectAnswer = (ObjectAnswer) objectList.get(i);
                Integer objectConstructionId = objectAnswer.getObjectConstructionId();
                Integer buildingObjectId = objectAnswer.getBuildingObjectId();
                if (objectConstructionId != null) {
                    try {

                        ObjectConstructionDao objectConstructionDao = (ObjectConstructionDao) factory.getBean("objectConstructionDao");
                        ObjectConstruction objectConstruction = objectConstructionDao.getObjectConstruction(objectConstructionId);
                        referenceList.add("<a href='objectConstructions.html?typeId=" + objectConstruction.getTypeId() + "&objectId=" + objectConstruction.getObjectId() + "'>Вопрос по виду конструкции - " + objectConstruction.getConstructionType() + (objectConstruction.getDescription() == null ? "-" + objectConstruction.getDescription() : "") + "</a><br/>");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (buildingObjectId != null) {
                    try {

                        BuildingObjectDao buildingObjectDao = (BuildingObjectDao) factory.getBean("buildingObjectDao");
                        BuildingObject buildingObject = buildingObjectDao.getBuildingObject(buildingObjectId);
                        referenceList.add("<a href='buildingObjects.html?objectId=" + buildingObject.getObjectId() + "'>Вопрос по обследуемому объекту - " + buildingObject.getName() + "</a><br/>");
                    } catch (Exception e) {

                    }

                }
            }

        }

    }


}
TOP

Related Classes of com.vst.dao.util.RefferenceUtil

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.