public UMRResultObject insertDocumentation(UMRDocumentationDTO documentationDTO)
{
Session session = UMRHibernateUtil.getUmrSession();
Transaction tx = null;
List<UMRDTO> duplicateDocumentationList=null;
String objectType =documentationDTO.getId().getObjectType();
String objectName =documentationDTO.getId().getObjectName();
try
{
duplicateDocumentationList = dao.getFilteredDocumentationList(objectType, objectName, false, session);
if(duplicateDocumentationList.isEmpty())
{
tx = session.beginTransaction();
dao.insertDocumentation(documentationDTO, session);
tx.commit();
ro.setSuccess(true);
ro.getMessages().add("Record Inserted Successfully");
if (ro.isSuccess())
{
if("Domain".equals(objectType))
{
MMTUtil.getDomainDocumentationMap().put(objectName, documentationDTO.getDocumentationLink());
}
else if("DomainCombo".equals(objectType))
{
MMTUtil.getDomainDocumentationMap().put(objectName, documentationDTO.getDocumentationLink());
}
return ro;
}
}
else
{
ro.getMessages().add("Documentation for '" + objectName + "' "
+ objectType+ " already exists! \n");
logger.info("Documentation for '" + objectName + "' "
+ objectType+ " already exists! \n");
}
}
return ro;
}
public UMRResultObject updateDocumentation(UMRDocumentationDTO documentationDTO)
{
Session session = UMRHibernateUtil.getUmrSession();
Transaction tx = null;
try
{
String objectType = documentationDTO.getId().getObjectType();
if("Domain".equals(objectType))
{
MMTUtil.getDomainDocumentationMap().put(documentationDTO.getId().getObjectName(), documentationDTO.getDocumentationLink());
}
else if("DomainCombo".equals(objectType))
{
MMTUtil.getDomainDocumentationMap().put(documentationDTO.getId().getObjectName(), documentationDTO.getDocumentationLink());
}
tx = session.beginTransaction();
dao.updateDocumentation(documentationDTO, session);
tx.commit();
ro.setSuccess(true);
ro.getMessages().add("Record Updated Successfully");
if(ro.isSuccess())
{
if("Domain".equals(objectType))
{
MMTUtil.getDomainDocumentationMap().put(objectName, documentationDTO.getDocumentationLink());
}
else if("DomainCombo".equals(objectType))
{
MMTUtil.getDomainDocumentationMap().put(objectName, documentationDTO.getDocumentationLink());
}
return ro;
}
}
我不想ducplicate中的代碼,如果(ro.isSuccess()),並希望重構代碼,但不能從這個Java通用功能
我試圖使另一進一步得到任何方法爲它無法使用documentationDTO我應該怎麼辦
問題是什麼? – shmosel