}
@Transactional
public GatewayCategoryDetail saveGatewayCategoryDetail(GatewayCategory category,
String entityId, String entityUrl,String entityName, String layerOrder, Integer type,String areaNode,String url,String otherUrl) {
GatewayCategoryDetail detail = new GatewayCategoryDetail();
detail.setCategory(category);
detail.setEnabled(true);
if(!"null".equals(entityId)&&!"".equals(entityId)&&entityId!=null)
detail.setEntityId(entityId);
if(!"null".equals(entityUrl)&&!"".equals(entityUrl)&&entityUrl!=null)detail.setEntityUrl(entityUrl);
if(!"null".equals(otherUrl)&&!"".equals(otherUrl)&&otherUrl!=null)detail.setOtherUrl(otherUrl);
if(!"null".equals(areaNode)&&!"".equals(areaNode)&&areaNode!=null)detail.setAreaNode(areaNode);
if(!"null".equals(url)&&!"".equals(url)&&url!=null)detail.setUrl(url);
if("".equals(layerOrder) || layerOrder == null || "null".equals(layerOrder))
{
String hql = "from GatewayCategoryDetail d where d.enabled = true and d.category.id = " + category.getId();
hql += " order by d.layerOrder desc";
List<GatewayCategoryDetail> details = getHibernateTemplate().find(hql);
if(details.size() == 0)
{
detail.setLayerOrder("0001");
}else
{
Pattern pattern = Pattern.compile("([0-9]+)*");
Matcher m = pattern.matcher(details.get(0).getLayerOrder());
boolean b = m.matches();
if(b)
{
Integer order = Integer.parseInt(details.get(0).getLayerOrder());
String orderStr = "";
order ++;
if(order < 10)
{
orderStr = "000"+order;
}else if(order < 100)
{
orderStr = "00"+order;
}else if(order < 1000)
{
orderStr = "0"+order;
}else
{
orderStr = ""+order;
}
detail.setLayerOrder(orderStr);
}else
{
detail.setLayerOrder(details.get(0).getLayerOrder()+"1");
}
}
}else
detail.setLayerOrder(layerOrder);
detail.setType(type);
detail.setEntityName(entityName);
getHibernateTemplate().persist(detail);
return detail;
}