private MetadataElementEntity getEntity(final MetadataElementEntity bean) {
   if (bean != null && StringUtils.isNotBlank(bean.getId())) {
     return elementDAO.findById(bean.getId());
   } else {
     return null;
   }
 }
 @Override
 @Transactional
 public void addRequiredAttributes(ResourceEntity resource) {
   if (resource != null
       && resource.getType() != null
       && StringUtils.isNotBlank(resource.getType().getId())) {
     MetadataElementSearchBean sb = new MetadataElementSearchBean();
     sb.addTypeId(resource.getType().getId());
     List<MetadataElementEntity> elementList = elementDAO.getByExample(sb, -1, -1);
     if (CollectionUtils.isNotEmpty(elementList)) {
       for (MetadataElementEntity element : elementList) {
         if (element.isRequired()) {
           resourcePropDao.save(AttributeUtil.buildResAttribute(resource, element));
         }
       }
     }
   }
 }