@Override public boolean delete(Long id) { PropertyMeta propertyMeta = propertyMetaRepository.findOne(id); jdbcTemplate.execute(this.dropColumn(propertyMeta)); propertyMetaRepository.delete(propertyMeta); try { jdbcTemplate.execute(this.dropView(propertyMeta.getTenantId(), propertyMeta.getObjectName())); } catch (Exception e) { } jdbcTemplate.execute(this.createView(propertyMeta.getTenantId(), propertyMeta.getObjectName())); return true; }
@Override public boolean update(PropertyMeta propertyMeta) { propertyMetaRepository.saveAndFlush(propertyMeta); try { jdbcTemplate.execute(this.dropView(propertyMeta.getTenantId(), propertyMeta.getObjectName())); } catch (Exception e) { } jdbcTemplate.execute(this.createView(propertyMeta.getTenantId(), propertyMeta.getObjectName())); return true; }
@Override public boolean getByTenantIdAndObjectNameAndDisplayName( String tenantId, String objectName, String displayName) { List<PropertyMeta> propertiesMeta = propertyMetaRepository.findByTenantIdAndObjectNameAndDisplayName( tenantId, objectName, displayName); if (propertiesMeta != null && propertiesMeta.size() > 0) { return true; } return false; }
// create view T_ORDER_TENANT1005_VIEW as select order_id from T_ORDER private String createView(String tenantId, String objectName) { List<PropertyMeta> propertiesMeta = propertyMetaRepository.findByTenantIdAndObjectName(tenantId, objectName); StringBuffer createView = new StringBuffer(); createView .append("create view ") .append(objectName) .append("_") .append(tenantId) .append("_") .append("VIEW as select "); for (PropertyMeta propertyMeta : propertiesMeta) { createView .append(" ") .append(propertyMeta.getInternalName()) .append(" as ") .append(propertyMeta.getDisplayName()) .append(", "); } createView.deleteCharAt(createView.lastIndexOf(",")); createView.append(" from ").append(objectName); return createView.toString(); }
@Override public int getMaxParamIndexByTenantIdAndObjectNameAndType( String tenantId, String objectName, UDFTypeEnum type) { return propertyMetaRepository.findMaxParamIndexByTenantIdAndObjectNameAndType( tenantId, objectName, type); }
@Override public PropertyMeta get(Long id) { return propertyMetaRepository.findOne(id); }
@Override public List<PropertyMeta> getByTenantIdAndObjectName(String tenantId, String objectName) { return propertyMetaRepository.findByTenantIdAndObjectName(tenantId, objectName); }