@Test public void getCurrentValueQueryWithoutAssetIdsTest() { final Set<Long> assetIds = new HashSet<Long>(); final String expectedQuery = CURRENTVALUEBASEQUERY + " group by assetid) groupedvalue " + "ON ungroupedvalue.assetid=groupedvalue.assetid and ungroupedvalue.createdtime=groupedvalue.createdtime " + "where ungroupedvalue.tenantid='ap.kurnool' "; assertEquals(expectedQuery, currentValueQueryBuilder.getCurrentValueQuery(assetIds, "ap.kurnool")); }
public String getCurrentValueQuery(final Set<Long> assetIds, final String tenantId) { String assetIdString = ""; if (assetIds != null && !assetIds.isEmpty()) assetIdString = "AND assetid IN " + getIdQueryForList(assetIds); return "SELECT ungroupedvalue.* FROM egasset_current_value ungroupedvalue " + "INNER join (SELECT assetid,max(createdtime) AS createdtime FROM egasset_current_value " + "WHERE tenantid='" + tenantId + "'" + assetIdString + " group by assetid) groupedvalue " + "ON ungroupedvalue.assetid=groupedvalue.assetid and ungroupedvalue.createdtime=groupedvalue.createdtime " + "where ungroupedvalue.tenantid='" + tenantId + "' " + assetIdString.replace( "assetid", "ungroupedvalue.assetid"); }
CurrentValueQueryBuilder { public String getCurrentValueQuery(final Set<Long> assetIds, final String tenantId) { String assetIdString = ""; if (assetIds != null && !assetIds.isEmpty()) assetIdString = "AND assetid IN " + getIdQueryForList(assetIds); return "SELECT ungroupedvalue.* FROM egasset_current_value ungroupedvalue " + "INNER join (SELECT assetid,max(createdtime) AS createdtime FROM egasset_current_value " + "WHERE tenantid='" + tenantId + "'" + assetIdString + " group by assetid) groupedvalue " + "ON ungroupedvalue.assetid=groupedvalue.assetid and ungroupedvalue.createdtime=groupedvalue.createdtime " + "where ungroupedvalue.tenantid='" + tenantId + "' " + assetIdString.replace( "assetid", "ungroupedvalue.assetid"); } }
CurrentValueQueryBuilder { public String getCurrentValueQuery(final Set<Long> assetIds, final String tenantId) { String assetIdString = ""; if (assetIds != null && !assetIds.isEmpty()) assetIdString = "AND assetid IN " + getIdQueryForList(assetIds); return "SELECT ungroupedvalue.* FROM egasset_current_value ungroupedvalue " + "INNER join (SELECT assetid,max(createdtime) AS createdtime FROM egasset_current_value " + "WHERE tenantid='" + tenantId + "'" + assetIdString + " group by assetid) groupedvalue " + "ON ungroupedvalue.assetid=groupedvalue.assetid and ungroupedvalue.createdtime=groupedvalue.createdtime " + "where ungroupedvalue.tenantid='" + tenantId + "' " + assetIdString.replace( "assetid", "ungroupedvalue.assetid"); }  }
CurrentValueQueryBuilder { public String getCurrentValueQuery(final Set<Long> assetIds, final String tenantId) { String assetIdString = ""; if (assetIds != null && !assetIds.isEmpty()) assetIdString = "AND assetid IN " + getIdQueryForList(assetIds); return "SELECT ungroupedvalue.* FROM egasset_current_value ungroupedvalue " + "INNER join (SELECT assetid,max(createdtime) AS createdtime FROM egasset_current_value " + "WHERE tenantid='" + tenantId + "'" + assetIdString + " group by assetid) groupedvalue " + "ON ungroupedvalue.assetid=groupedvalue.assetid and ungroupedvalue.createdtime=groupedvalue.createdtime " + "where ungroupedvalue.tenantid='" + tenantId + "' " + assetIdString.replace( "assetid", "ungroupedvalue.assetid"); }  String getInsertQuery(); String getCurrentValueQuery(final Set<Long> assetIds, final String tenantId); String getUpdateQuery(); }
CurrentValueQueryBuilder { public String getCurrentValueQuery(final Set<Long> assetIds, final String tenantId) { String assetIdString = ""; if (assetIds != null && !assetIds.isEmpty()) assetIdString = "AND assetid IN " + getIdQueryForList(assetIds); return "SELECT ungroupedvalue.* FROM egasset_current_value ungroupedvalue " + "INNER join (SELECT assetid,max(createdtime) AS createdtime FROM egasset_current_value " + "WHERE tenantid='" + tenantId + "'" + assetIdString + " group by assetid) groupedvalue " + "ON ungroupedvalue.assetid=groupedvalue.assetid and ungroupedvalue.createdtime=groupedvalue.createdtime " + "where ungroupedvalue.tenantid='" + tenantId + "' " + assetIdString.replace( "assetid", "ungroupedvalue.assetid"); }  String getInsertQuery(); String getCurrentValueQuery(final Set<Long> assetIds, final String tenantId); String getUpdateQuery();  }