@Override protected ProfileFilterRecordDto newRecord() { return new ProfileFilterRecordDto(); }
@Override public int compareTo(ProfileFilterRecordDto profileFilterRecordDto) { int endpointProfileShemaVersion = getEndpointProfileSchemaVersion() != null ? getEndpointProfileSchemaVersion() : -1; int otherEndpointProfileShemaVersion = profileFilterRecordDto.getEndpointProfileSchemaVersion() != null ? profileFilterRecordDto.getEndpointProfileSchemaVersion() : -1; int result = endpointProfileShemaVersion - otherEndpointProfileShemaVersion; if (result == 0) { int serverProfileShemaVersion = getServerProfileSchemaVersion() != null ? getServerProfileSchemaVersion() : -1; int otherServerProfileShemaVersion = profileFilterRecordDto.getServerProfileSchemaVersion() != null ? profileFilterRecordDto.getServerProfileSchemaVersion() : -1; result = serverProfileShemaVersion - otherServerProfileShemaVersion; } return result; }
Integer versionEnd = record.getEndpointProfileSchemaVersion(); Integer versionSer = record.getServerProfileSchemaVersion(); String endpointProfileVersion = versionEnd != null ? versionEnd.intValue() + "" : ""; String serverProfileVersion = versionSer != null ? versionSer.intValue() + "" : ""; recordView.getServerProfileSchemaVersion().setValue(serverProfileVersion); if (record.hasActive() && !record.hasDraft()) { ProfileFilterDto inactiveStruct = createInactiveStruct(); inactiveStruct.setEndpointProfileSchemaId(record.getEndpointProfileSchemaId()); inactiveStruct.setEndpointProfileSchemaVersion(record.getEndpointProfileSchemaVersion()); inactiveStruct.setServerProfileSchemaId(record.getServerProfileSchemaId()); inactiveStruct.setServerProfileSchemaVersion(record.getServerProfileSchemaVersion()); inactiveStruct.setDescription(record.getDescription()); inactiveStruct.setBody(record.getActiveStructureDto().getBody()); record.setInactiveStructureDto(inactiveStruct); recordView.getRecordPanel().setReadOnly(); if (showActive && record.hasActive()) { recordView.getRecordPanel().openActive(); } else {
String endpointProfileSchemaId, String serverProfileSchemaId, String endpointGroupId) { validateFilterSchemaIds(endpointProfileSchemaId, serverProfileSchemaId); ProfileFilterRecordDto record = new ProfileFilterRecordDto(); Collection<ProfileFilterDto> profileFilters = convertDtoList( profileFilterDao.findActualBySchemaIdAndGroupId(endpointProfileSchemaId, for (ProfileFilterDto profileFilter : profileFilters) { if (profileFilter.getStatus() == UpdateStatus.ACTIVE) { record.setActiveStructureDto(profileFilter); } else if (profileFilter.getStatus() == UpdateStatus.INACTIVE) { record.setInactiveStructureDto(profileFilter); if (!record.hasActive()) { ProfileFilterDto deprecatedProfileFilter = getDto( profileFilterDao.findLatestDeprecated(endpointProfileSchemaId, serverProfileSchemaId, endpointGroupId)); if (deprecatedProfileFilter != null) { record.setActiveStructureDto(deprecatedProfileFilter); if (record.isEmpty()) { LOG.debug("Can't find related profile filter record for endpoint schema {}, " + "server schema {} and group {}.", endpointProfileSchemaId,
/** * All-args constructor. */ public static List<ProfileFilterRecordDto> convertToProfileFilterRecords( Collection<ProfileFilterDto> profileFilters) { Map<ProfileVersionPairDto, ProfileFilterRecordDto> profileFiltterRecordsMap = new HashMap<>(); for (ProfileFilterDto profileFilter : profileFilters) { ProfileVersionPairDto versionPair = new ProfileVersionPairDto( profileFilter.getEndpointProfileSchemaId(), profileFilter.getEndpointProfileSchemaVersion(), profileFilter.getServerProfileSchemaId(), profileFilter.getServerProfileSchemaVersion()); ProfileFilterRecordDto profileFilterRecord = profileFiltterRecordsMap.get(versionPair); if (profileFilterRecord == null) { profileFilterRecord = new ProfileFilterRecordDto(); profileFiltterRecordsMap.put(versionPair, profileFilterRecord); } if (profileFilter.getStatus() == UpdateStatus.ACTIVE) { profileFilterRecord.setActiveStructureDto(profileFilter); } else if (profileFilter.getStatus() == UpdateStatus.INACTIVE) { profileFilterRecord.setInactiveStructureDto(profileFilter); } } return new ArrayList<>(profileFiltterRecordsMap.values()); }
@Override public Collection<ProfileFilterRecordDto> findAllProfileFilterRecordsByEndpointGroupId( String endpointGroupId, boolean includeDeprecated) { Collection<ProfileFilterDto> profileFilters = convertDtoList( profileFilterDao.findActualByEndpointGroupId(endpointGroupId)); List<ProfileFilterRecordDto> records = ProfileFilterRecordDto.convertToProfileFilterRecords( profileFilters); if (includeDeprecated) { List<ProfileVersionPairDto> versions = findVacantSchemasByEndpointGroupId(endpointGroupId); for (ProfileVersionPairDto version : versions) { ProfileFilterDto deprecatedProfileFilter = getDto(profileFilterDao.findLatestDeprecated( version.getEndpointProfileSchemaid(), version.getServerProfileSchemaid(), endpointGroupId)); if (deprecatedProfileFilter != null) { ProfileFilterRecordDto record = new ProfileFilterRecordDto(); record.setActiveStructureDto(deprecatedProfileFilter); records.add(record); } } } Collections.sort(records); return records; }
@Override public String getValue(ProfileFilterRecordDto item) { return item.getEndpointProfileSchemaVersion() != null ? item.getEndpointProfileSchemaVersion() + "" : ""; } }, 60);
@Override public String getValue(ProfileFilterRecordDto item) { return item.getServerProfileSchemaVersion() != null ? item.getServerProfileSchemaVersion() + "" : ""; } }, 60);
@Test public void findAllProfileFilterRecordsByEndpointGroupIdTest() { ApplicationDto app = generateApplicationDto(null); String appId = app.getId(); EndpointGroupDto groupDto = generateEndpointGroupDto(appId); EndpointProfileSchemaDto schema = generateProfSchemaDto(app.getTenantId(), appId, 1).get(0); ServerProfileSchemaDto serverProfileSchema = generateServerProfileSchema(app.getId(), app.getTenantId()); ProfileFilterDto filter = generateFilterDto(schema.getId(), serverProfileSchema.getId(), groupDto.getId(), 3, true).get(2); Assert.assertEquals(UpdateStatus.ACTIVE, filter.getStatus()); profileService.deactivateProfileFilter(filter.getId(), null); List<ProfileFilterRecordDto> records = (List<ProfileFilterRecordDto>) profileService.findAllProfileFilterRecordsByEndpointGroupId(groupDto.getId(), true); Assert.assertNotNull(records); Assert.assertEquals(1, records.size()); Assert.assertEquals(UpdateStatus.DEPRECATED, records.get(0).getActiveStructureDto().getStatus()); }