public ApplicationEntity(String siteId, String appType) { this.site = new SiteEntity("", siteId); ApplicationDesc applicationDesc = new ApplicationDesc(); applicationDesc.setType(appType); this.descriptor = applicationDesc; this.mode = null; this.status = null; }
@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 SiteEntity getBySiteId(String siteId) throws EntityNotFoundException { List<SiteEntity> results; SiteEntity siteEntity = new SiteEntity("", siteId); try { results = queryService.queryWithCond(selectSqlBySiteId, siteEntity, new SiteEntityToRelation(), new RelationToSiteEntity()); } catch (SQLException e) { LOGGER.error("Error to getBySiteId SiteEntity: {}", e); throw new EntityNotFoundException(e); } if (results.isEmpty()) { throw new EntityNotFoundException("getBySiteId " + siteId + " Not Found"); } return results.get(0); }
@Override public SiteEntity getByUUID(String uuid) throws EntityNotFoundException { List<SiteEntity> results; SiteEntity siteEntity = new SiteEntity(uuid, ""); try { results = queryService.queryWithCond(selectSqlByUUID, siteEntity, new SiteEntityToRelation(), new RelationToSiteEntity()); } catch (SQLException e) { LOGGER.error("Error to getByUUID SiteEntity: {}", e); throw new EntityNotFoundException(e); } if (results.isEmpty()) { throw new EntityNotFoundException("getByUUID " + uuid + " Not Found"); } return results.get(0); }
@Override public SiteEntity deleteByUUID(String uuid) throws EntityNotFoundException { SiteEntity siteEntity = new SiteEntity(uuid, ""); int result; try { result = queryService.update(deleteSqlByUUID, siteEntity, new SiteEntityToRelation()); } catch (SQLException e) { LOGGER.error("Error to deleteByUUID SiteEntity: {}", siteEntity, e); throw new EntityNotFoundException(e); } if (result == 0) { throw new EntityNotFoundException("deleteByUUID " + siteEntity + "Not Found"); } return siteEntity; }
@Override public SiteEntity deleteBySiteId(String siteId) throws EntityNotFoundException { SiteEntity siteEntity = new SiteEntity("", siteId); int result; try { result = queryService.update(deleteSqlBySiteId, siteEntity, new SiteEntityToRelation()); } catch (SQLException e) { LOGGER.error("Error to deleteBySiteId SiteEntity: {}", siteEntity, e); throw new EntityNotFoundException(e); } if (result == 0) { throw new EntityNotFoundException("deleteBySiteId " + siteEntity + "Not Found"); } return siteEntity; }
private SiteEntity getUniqueSite() { // Create local site SiteEntity siteEntity = new SiteEntity(); siteEntity.setSiteId("SIMULATED_SITE_" + incr.incrementAndGet()); siteEntity.setSiteName(siteEntity.getSiteId()); siteEntity.setDescription("Automatically generated unique simulation site " + siteEntity.getSiteId() + " (simulator: " + this + ")"); return siteEntity; }
@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; }