@Override public SiteEntity apply(ResultSet resultSet) throws SQLException { SiteEntity siteEntityResult = new SiteEntity(); siteEntityResult.setUuid(resultSet.getString(1)); siteEntityResult.setSiteId(resultSet.getString(2)); siteEntityResult.setSiteName(resultSet.getString(3)); siteEntityResult.setDescription(resultSet.getString(4)); siteEntityResult.setCreatedTime(resultSet.getLong(5)); siteEntityResult.setModifiedTime(resultSet.getLong(6)); return siteEntityResult; } }
@Override public ApplicationEntity apply(ResultSet resultSet) throws SQLException { ApplicationDesc applicationDesc = new ApplicationDesc(); String appType = resultSet.getString(4); applicationDesc.setType(appType); SiteEntity siteEntity = new SiteEntity(); siteEntity.setUuid(resultSet.getString(12)); siteEntity.setSiteId(resultSet.getString(13)); siteEntity.setSiteName(resultSet.getString(14)); siteEntity.setDescription(resultSet.getString(15)); siteEntity.setCreatedTime(resultSet.getLong(16)); siteEntity.setModifiedTime(resultSet.getLong(17)); ApplicationEntity resultEntity = new ApplicationEntity(); resultEntity.setUuid(resultSet.getString(1)); resultEntity.setAppId(resultSet.getString(2)); resultEntity.setSite(siteEntity); resultEntity.setDescriptor(applicationDesc); resultEntity.setMode(ApplicationEntity.Mode.valueOf(resultSet.getString(5))); resultEntity.setJarPath(resultSet.getString(6)); resultEntity.setStatus(ApplicationEntity.Status.valueOf(resultSet.getString(7))); resultEntity.setConfiguration(parse(resultSet.getString(8))); resultEntity.setContext(parse(resultSet.getString(9))); resultEntity.setCreatedTime(resultSet.getLong(10)); resultEntity.setModifiedTime(resultSet.getLong(11)); return resultEntity; }
@Override public SiteEntity update(SiteEntity siteEntity) throws EntityNotFoundException { if (siteEntity.getSiteId() == null && siteEntity.getUuid() == null) { throw new IllegalArgumentException("siteId and UUID are both null, don't know how to update"); } SiteEntity oldEntity = (siteEntity.getSiteId() != null) ? getBySiteId(siteEntity.getSiteId()) : getByUUID(siteEntity.getUuid()); siteEntity.setUuid(oldEntity.getUuid()); siteEntity.setCreatedTime(oldEntity.getCreatedTime()); siteEntity.ensureDefault(); siteId2EntityMap.put(siteEntity.getSiteId(), siteEntity); return siteEntity; } }
@Override public SiteEntity update(SiteEntity siteEntity) throws EntityNotFoundException { if (siteEntity.getSiteId() == null && siteEntity.getUuid() == null) { throw new IllegalArgumentException("siteId and UUID are both null, don't know how to update"); } int result; try { SiteEntity oldEntity = getBySiteId(siteEntity.getSiteId()); siteEntity.setUuid(oldEntity.getUuid()); siteEntity.setCreatedTime(oldEntity.getCreatedTime()); siteEntity.ensureDefault(); result = queryService.update(updateSqlByUUID, siteEntity, new SiteEntityToRelation()); } catch (SQLException e) { LOGGER.error("Error to update SiteEntity: {}", siteEntity, e); throw new EntityNotFoundException(e); } if (result == 0) { throw new EntityNotFoundException("update " + siteEntity + "Not Found"); } return siteEntity; }