public ModelNominalLabelDTO(ModelNominalLabel modelNominalLabel) throws PropertyNotSetException { if (modelNominalLabel != null) { this.setLabelPrecision(modelNominalLabel.getLabelPrecision()); this.setLabelRecall(modelNominalLabel.getLabelRecall()); this.setLabelAuc(modelNominalLabel.getLabelAuc()); this.setClassifiedDocumentCount(modelNominalLabel.getClassifiedDocumentCount()); if (modelNominalLabel.getId() != null) { this.setIdDTO(new ModelNominalLabelIdDTO(modelNominalLabel.getId())); } else { throw new PropertyNotSetException("Primary key not set!"); } if (modelNominalLabel.hasModel()) { Model m = new Model( modelNominalLabel.getModel().getModelFamily(), modelNominalLabel.getModel().getAvgPrecision(), modelNominalLabel.getModel().getAvgRecall(), modelNominalLabel.getModel().getAvgAuc(), modelNominalLabel.getModel().getTrainingCount(), modelNominalLabel.getModel().getTrainingTime(), modelNominalLabel.getModel().isIsCurrentModel()); Long modelID = new Long(modelNominalLabel.getModel().getModelId()); m.setModelId(modelID); this.setModelDTO(new ModelDTO(m)); } if (modelNominalLabel.hasNominalLabel()) { NominalLabel nb = new NominalLabel( modelNominalLabel.getNominalLabel().getNominalAttribute(), modelNominalLabel.getNominalLabel().getNominalLabelCode(), modelNominalLabel.getNominalLabel().getName(), modelNominalLabel.getNominalLabel().getDescription(), modelNominalLabel.getNominalLabel().getSequence()); nb.setNominalLabelId(modelNominalLabel.getNominalLabel().getNominalLabelId()); this.setNominalLabelDTO(new NominalLabelDTO(nb)); } } }
@Override public List<ModelNominalLabelDTO> getAllModelNominalLabelsByModelID( Long modelID, String crisisCode) { List<ModelNominalLabelDTO> dtoList = new ArrayList<ModelNominalLabelDTO>(); ; List<ModelNominalLabel> modelNominalLabelList = new ArrayList<ModelNominalLabel>(); Model model = modelEJB.getById(modelID); if (model != null) { logger.info( "Model is not NULL in getAllModelNominalLabelsByModelID for modelID = " + modelID + ",crisis code = " + crisisCode); Hibernate.initialize(model.getModelFamily()); try { Boolean modelStatus = model.getModelFamily().isIsActive(); // getting model status ModelFamily modelFamily = model.getModelFamily(); Hibernate.initialize(modelFamily.getNominalAttribute()); Long nominalAttributeId = modelFamily.getNominalAttribute().getNominalAttributeId(); // Long nominalAttributeId = // model.getModelFamily().getNominalAttribute().getNominalAttributeId(); modelNominalLabelList = this.getAllByCriteria(Restrictions.eq("id.modelId", modelID)); logger.info( "modelNominalLabellist size = " + (modelNominalLabelList != null ? modelNominalLabelList.size() : "null")); for (ModelNominalLabel labelEntity : modelNominalLabelList) { // Getting training examples for each label int trainingSet = 0; NominalLabel nominalLabel = labelEntity.getNominalLabel(); if (nominalLabel != null && !nominalLabel.getNominalLabelCode().equalsIgnoreCase("null")) { try { trainingSet = documentEJB.getDocumentCountForNominalLabelAndCrisis( nominalLabel.getNominalLabelId(), crisisCode); } catch (Exception e) { // TODO Auto-generated catch block logger.error("Error in getDocumentCollectionWithNominalLabelData.", e); } } // Deep copying modelNominalLabel to ModelNominalLabelDTO Hibernate.initialize(labelEntity.getModel()); Hibernate.initialize(labelEntity.getNominalLabel()); ModelNominalLabelDTO dto = new ModelNominalLabelDTO(labelEntity); dto.setModelStatus(modelStatus == true ? "RUNNING" : "NOT RUNNING"); dto.setNominalAttributeId(nominalAttributeId); dto.setTrainingDocuments(trainingSet); dtoList.add(dto); } } catch (Exception e) { logger.error("Exception occured in getAllModelNominalLabelsByModelID \n\n", e); return null; } } return dtoList; }