Merge pull request #107 from bsinno/complete-rep-tests
Complete repository tests
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.security;
|
package org.eclipse.hawkbit.security;
|
||||||
|
|
||||||
import static org.fest.assertions.Assertions.assertThat;
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -20,6 +21,7 @@ import org.springframework.security.authentication.InsufficientAuthenticationExc
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
@@ -38,11 +40,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private TenantAwareWebAuthenticationDetails webAuthenticationDetailsMock;
|
private TenantAwareWebAuthenticationDetails webAuthenticationDetailsMock;
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* Testing in case the containing controllerId in the URI request path does
|
@Description("Testing in case the containing controllerId in the URI request path does not accord with the controllerId in the request header.")
|
||||||
* not accord with the controllerId in the request header.
|
|
||||||
*/
|
|
||||||
@Test(expected = BadCredentialsException.class)
|
|
||||||
public void principalAndCredentialsNotTheSameThrowsAuthenticationException() {
|
public void principalAndCredentialsNotTheSameThrowsAuthenticationException() {
|
||||||
final String principal = "controllerIdURL";
|
final String principal = "controllerIdURL";
|
||||||
final String credentials = "controllerIdHeader";
|
final String credentials = "controllerIdHeader";
|
||||||
@@ -51,15 +50,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
token.setDetails(webAuthenticationDetailsMock);
|
token.setDetails(webAuthenticationDetailsMock);
|
||||||
|
|
||||||
// test, should throw authentication exception
|
// test, should throw authentication exception
|
||||||
underTestWithoutSourceIpCheck.authenticate(token);
|
try {
|
||||||
|
underTestWithoutSourceIpCheck.authenticate(token);
|
||||||
|
fail("Should not work with wrong credentials");
|
||||||
|
} catch (final BadCredentialsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Testing that the controllerId within the URI request path is the same
|
|
||||||
* with the controllerId within the request header and no source IP check is
|
|
||||||
* in place.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
|
@Description("Testing that the controllerId within the URI request path is the same with the controllerId within the request header and no source IP check is in place.")
|
||||||
public void principalAndCredentialsAreTheSameWithNoSourceIpCheckIsSuccessful() {
|
public void principalAndCredentialsAreTheSameWithNoSourceIpCheckIsSuccessful() {
|
||||||
final String principal = "controllerId";
|
final String principal = "controllerId";
|
||||||
final String credentials = "controllerId";
|
final String credentials = "controllerId";
|
||||||
@@ -71,12 +72,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* Testing that the controllerId in the URI request match with the
|
@Description("Testing that the controllerId in the URI request match with the controllerId in the request header but the request are not coming from a trustful source.")
|
||||||
* controllerId in the request header but the request are not coming from a
|
|
||||||
* trustful source.
|
|
||||||
*/
|
|
||||||
@Test(expected = InsufficientAuthenticationException.class)
|
|
||||||
public void priniciapAndCredentialsAreTheSameButSourceIpRequestNotMatching() {
|
public void priniciapAndCredentialsAreTheSameButSourceIpRequestNotMatching() {
|
||||||
final String remoteAddress = "192.168.1.1";
|
final String remoteAddress = "192.168.1.1";
|
||||||
final String principal = "controllerId";
|
final String principal = "controllerId";
|
||||||
@@ -88,16 +85,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
when(webAuthenticationDetailsMock.getRemoteAddress()).thenReturn(remoteAddress);
|
when(webAuthenticationDetailsMock.getRemoteAddress()).thenReturn(remoteAddress);
|
||||||
|
|
||||||
// test, should throw authentication exception
|
// test, should throw authentication exception
|
||||||
final Authentication authenticate = underTestWithSourceIpCheck.authenticate(token);
|
|
||||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
try {
|
||||||
|
underTestWithSourceIpCheck.authenticate(token);
|
||||||
|
fail("as source is not trusted.");
|
||||||
|
} catch (final InsufficientAuthenticationException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* Testing that the controllerId in the URI request match with the
|
@Description("Testing that the controllerId in the URI request match with the controllerId in the request header and the source Ip is matching the allowed remote IP address.")
|
||||||
* controllerId in the request header and the source Ip is matching the
|
|
||||||
* allowed remote IP address.
|
|
||||||
*/
|
|
||||||
@Test()
|
|
||||||
public void priniciapAndCredentialsAreTheSameAndSourceIpIsTrusted() {
|
public void priniciapAndCredentialsAreTheSameAndSourceIpIsTrusted() {
|
||||||
final String principal = "controllerId";
|
final String principal = "controllerId";
|
||||||
final String credentials = "controllerId";
|
final String credentials = "controllerId";
|
||||||
@@ -112,7 +110,7 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test
|
||||||
public void priniciapAndCredentialsAreTheSameAndSourceIpIsWithinList() {
|
public void priniciapAndCredentialsAreTheSameAndSourceIpIsWithinList() {
|
||||||
final String[] trustedIPAddresses = new String[] { "192.168.1.1", "192.168.1.2", REQUEST_SOURCE_IP,
|
final String[] trustedIPAddresses = new String[] { "192.168.1.1", "192.168.1.2", REQUEST_SOURCE_IP,
|
||||||
"192.168.1.3" };
|
"192.168.1.3" };
|
||||||
@@ -148,6 +146,11 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
|
|
||||||
// test, should throw authentication exception
|
// test, should throw authentication exception
|
||||||
final Authentication authenticate = underTestWithList.authenticate(token);
|
final Authentication authenticate = underTestWithList.authenticate(token);
|
||||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
try {
|
||||||
|
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||||
|
fail("as source is not trusted.");
|
||||||
|
} catch (final InsufficientAuthenticationException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler;
|
import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler;
|
||||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder;
|
import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
|
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
||||||
@@ -127,23 +127,11 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
|||||||
return new ExceptionMappingAspectHandler();
|
return new ExceptionMappingAspectHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
|
|
||||||
* createJpaVendorAdapter()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
|
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
|
||||||
return new EclipseLinkJpaVendorAdapter();
|
return new EclipseLinkJpaVendorAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
|
|
||||||
* getVendorProperties()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> getVendorProperties() {
|
protected Map<String, Object> getVendorProperties() {
|
||||||
|
|
||||||
|
|||||||
@@ -167,11 +167,6 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.core.Ordered#getOrder()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import org.eclipse.hawkbit.eventbus.event.RolloutGroupPropertyChangeEvent;
|
|||||||
import org.eclipse.hawkbit.eventbus.event.RolloutPropertyChangeEvent;
|
import org.eclipse.hawkbit.eventbus.event.RolloutPropertyChangeEvent;
|
||||||
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
|
||||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
||||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||||
@@ -36,13 +36,7 @@ import com.google.common.eventbus.EventBus;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.persistence.descriptors.DescriptorEventAdapter#postInsert
|
|
||||||
* (org.eclipse.persistence.descriptors.DescriptorEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void postInsert(final DescriptorEvent event) {
|
public void postInsert(final DescriptorEvent event) {
|
||||||
if (event.getObject().getClass().equals(Action.class)) {
|
if (event.getObject().getClass().equals(Action.class)) {
|
||||||
@@ -56,30 +50,18 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.persistence.descriptors.DescriptorEventAdapter#postUpdate
|
|
||||||
* (org.eclipse.persistence.descriptors.DescriptorEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void postUpdate(final DescriptorEvent event) {
|
public void postUpdate(final DescriptorEvent event) {
|
||||||
if (event.getObject().getClass().equals(Action.class)) {
|
if (event.getObject().getClass().equals(Action.class)) {
|
||||||
getAfterTransactionCommmitExecutor().afterCommit(
|
getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
|
||||||
() -> getEventBus()
|
new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class, event))));
|
||||||
.post(new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class,
|
|
||||||
event))));
|
|
||||||
} else if (event.getObject().getClass().equals(Rollout.class)) {
|
} else if (event.getObject().getClass().equals(Rollout.class)) {
|
||||||
getAfterTransactionCommmitExecutor().afterCommit(
|
getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
|
||||||
() -> getEventBus().post(
|
new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class, event))));
|
||||||
new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class,
|
|
||||||
event))));
|
|
||||||
} else if (event.getObject().getClass().equals(RolloutGroup.class)) {
|
} else if (event.getObject().getClass().equals(RolloutGroup.class)) {
|
||||||
getAfterTransactionCommmitExecutor().afterCommit(
|
getAfterTransactionCommmitExecutor().afterCommit(
|
||||||
() -> getEventBus().post(
|
() -> getEventBus().post(new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(),
|
||||||
new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(), getChangeSet(
|
getChangeSet(RolloutGroup.class, event))));
|
||||||
RolloutGroup.class, event))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,14 +69,11 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
|||||||
final Class<T> clazz, final DescriptorEvent event) {
|
final Class<T> clazz, final DescriptorEvent event) {
|
||||||
final T rolloutGroup = clazz.cast(event.getObject());
|
final T rolloutGroup = clazz.cast(event.getObject());
|
||||||
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
||||||
return changeSet
|
return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||||
.getChanges()
|
|
||||||
.stream()
|
|
||||||
.filter(record -> record instanceof DirectToFieldChangeRecord)
|
|
||||||
.map(record -> (DirectToFieldChangeRecord) record)
|
.map(record -> (DirectToFieldChangeRecord) record)
|
||||||
.collect(
|
.collect(Collectors.toMap(record -> record.getAttribute(),
|
||||||
Collectors.toMap(record -> record.getAttribute(), record -> new AbstractPropertyChangeEvent<T>(
|
record -> new AbstractPropertyChangeEvent<T>(rolloutGroup, null).new Values(
|
||||||
rolloutGroup, null).new Values(record.getOldValue(), record.getNewValue())));
|
record.getOldValue(), record.getNewValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AfterTransactionCommitExecutor getAfterTransactionCommmitExecutor() {
|
private AfterTransactionCommitExecutor getAfterTransactionCommmitExecutor() {
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ package org.eclipse.hawkbit.eventbus.event;
|
|||||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract definition class for {@link EntityEvent} for {@link TenantAwareBaseEntity}s,
|
* An abstract definition class for {@link EntityEvent} for
|
||||||
* which holds the {@link TenantAwareBaseEntity}.
|
* {@link TenantAwareBaseEntity}s, which holds the {@link TenantAwareBaseEntity}
|
||||||
|
* .
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -37,33 +38,16 @@ public abstract class AbstractBaseEntityEvent<E extends TenantAwareBaseEntity> e
|
|||||||
this.entity = baseEntity;
|
this.entity = baseEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public E getEntity() {
|
public E getEntity() {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity(java.lang
|
|
||||||
* .Class)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T getEntity(final Class<T> entityClass) {
|
public <T> T getEntity(final Class<T> entityClass) {
|
||||||
return entityClass.cast(entity);
|
return entityClass.cast(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getTenant()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getTenant() {
|
public String getTenant() {
|
||||||
return entity.getTenant();
|
return entity.getTenant();
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.eventbus.event;
|
package org.eclipse.hawkbit.eventbus.event;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A event for assignment target tag.
|
* A event for assignment target tag.
|
||||||
*/
|
*/
|
||||||
public class DistributionSetTagAssigmentResultEvent {
|
public class DistributionSetTagAssigmentResultEvent {
|
||||||
|
|
||||||
private final DistributionSetTagAssigmentResult assigmentResult;
|
private final DistributionSetTagAssignmentResult assigmentResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -23,11 +23,11 @@ public class DistributionSetTagAssigmentResultEvent {
|
|||||||
* @param assigmentResult
|
* @param assigmentResult
|
||||||
* the assignment result-
|
* the assignment result-
|
||||||
*/
|
*/
|
||||||
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssigmentResult assigmentResult) {
|
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult) {
|
||||||
this.assigmentResult = assigmentResult;
|
this.assigmentResult = assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DistributionSetTagAssigmentResult getAssigmentResult() {
|
public DistributionSetTagAssignmentResult getAssigmentResult() {
|
||||||
return assigmentResult;
|
return assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.eventbus.event;
|
package org.eclipse.hawkbit.eventbus.event;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A event for assignment target tag.
|
* A event for assignment target tag.
|
||||||
*/
|
*/
|
||||||
public class TargetTagAssigmentResultEvent {
|
public class TargetTagAssigmentResultEvent {
|
||||||
|
|
||||||
private final TargetTagAssigmentResult assigmentResult;
|
private final TargetTagAssignmentResult assigmentResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -23,11 +23,11 @@ public class TargetTagAssigmentResultEvent {
|
|||||||
* @param assigmentResult
|
* @param assigmentResult
|
||||||
* the assignment result-
|
* the assignment result-
|
||||||
*/
|
*/
|
||||||
public TargetTagAssigmentResultEvent(final TargetTagAssigmentResult assigmentResult) {
|
public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult) {
|
||||||
this.assigmentResult = assigmentResult;
|
this.assigmentResult = assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetTagAssigmentResult getAssigmentResult() {
|
public TargetTagAssignmentResult getAssigmentResult() {
|
||||||
return assigmentResult;
|
return assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -376,16 +376,9 @@ public class ControllerManagement {
|
|||||||
switch (actionStatus.getStatus()) {
|
switch (actionStatus.getStatus()) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
mergedTarget = deploymentManagement.updateTargetInfo(mergedTarget, TargetUpdateStatus.ERROR, false);
|
mergedTarget = deploymentManagement.updateTargetInfo(mergedTarget, TargetUpdateStatus.ERROR, false);
|
||||||
// set action inactive
|
handleErrorOnAction(mergedAction, mergedTarget);
|
||||||
mergedAction.setActive(false);
|
|
||||||
mergedAction.setStatus(Status.ERROR);
|
|
||||||
mergedTarget.setAssignedDistributionSet(null);
|
|
||||||
targetManagement.updateTarget(mergedTarget);
|
|
||||||
break;
|
break;
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
// set action inactive
|
|
||||||
mergedAction.setActive(false);
|
|
||||||
mergedAction.setStatus(Status.FINISHED);
|
|
||||||
handleFinishedAndStoreInTargetStatus(mergedTarget, mergedAction);
|
handleFinishedAndStoreInTargetStatus(mergedTarget, mergedAction);
|
||||||
break;
|
break;
|
||||||
case CANCELED:
|
case CANCELED:
|
||||||
@@ -404,6 +397,13 @@ public class ControllerManagement {
|
|||||||
return actionRepository.save(mergedAction);
|
return actionRepository.save(mergedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleErrorOnAction(final Action mergedAction, final Target mergedTarget) {
|
||||||
|
mergedAction.setActive(false);
|
||||||
|
mergedAction.setStatus(Status.ERROR);
|
||||||
|
mergedTarget.setAssignedDistributionSet(null);
|
||||||
|
targetManagement.updateTarget(mergedTarget);
|
||||||
|
}
|
||||||
|
|
||||||
private void checkForToManyStatusEntries(final Action action) {
|
private void checkForToManyStatusEntries(final Action action) {
|
||||||
if (securityProperties.getDos().getMaxStatusEntriesPerAction() > 0) {
|
if (securityProperties.getDos().getMaxStatusEntriesPerAction() > 0) {
|
||||||
|
|
||||||
@@ -420,6 +420,8 @@ public class ControllerManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleFinishedAndStoreInTargetStatus(final Target target, final Action action) {
|
private void handleFinishedAndStoreInTargetStatus(final Target target, final Action action) {
|
||||||
|
action.setActive(false);
|
||||||
|
action.setStatus(Status.FINISHED);
|
||||||
final TargetInfo targetInfo = target.getTargetInfo();
|
final TargetInfo targetInfo = target.getTargetInfo();
|
||||||
final DistributionSet ds = entityManager.merge(action.getDistributionSet());
|
final DistributionSet ds = entityManager.merge(action.getDistributionSet());
|
||||||
targetInfo.setInstalledDistributionSet(ds);
|
targetInfo.setInstalledDistributionSet(ds);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class DistributionSetAssignmentResult extends AssignmentResult {
|
|||||||
* @return the assignedTargets
|
* @return the assignedTargets
|
||||||
*/
|
*/
|
||||||
public List<Target> getAssignedTargets() {
|
public List<Target> getAssignedTargets() {
|
||||||
return targetManagement.findTargetsByControllerID(assignedTargets);
|
return targetManagement.findTargetByControllerID(assignedTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata_;
|
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata_;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTypeElement;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTypeElement;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet_;
|
import org.eclipse.hawkbit.repository.model.DistributionSet_;
|
||||||
@@ -68,9 +68,6 @@ import com.google.common.eventbus.EventBus;
|
|||||||
/**
|
/**
|
||||||
* Business facade for managing the {@link DistributionSet}s.
|
* Business facade for managing the {@link DistributionSet}s.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@Validated
|
@Validated
|
||||||
@@ -140,15 +137,15 @@ public class DistributionSetManagement {
|
|||||||
* @param sets
|
* @param sets
|
||||||
* to toggle for
|
* to toggle for
|
||||||
* @param tag
|
* @param tag
|
||||||
* to toogle
|
* to toggle
|
||||||
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
|
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||||
* the assignment outcome.
|
* the assignment outcome.
|
||||||
*/
|
*/
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final List<DistributionSet> sets,
|
public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final List<DistributionSet> sets,
|
||||||
@NotNull final DistributionSetTag tag) {
|
@NotNull final DistributionSetTag tag) {
|
||||||
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
|
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
|
||||||
}
|
}
|
||||||
@@ -163,42 +160,43 @@ public class DistributionSetManagement {
|
|||||||
* to toggle for
|
* to toggle for
|
||||||
* @param tagName
|
* @param tagName
|
||||||
* to toggle
|
* to toggle
|
||||||
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
|
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||||
* the assignment outcome.
|
* the assignment outcome.
|
||||||
*/
|
*/
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection<Long> dsIds,
|
public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection<Long> dsIds,
|
||||||
@NotNull final String tagName) {
|
@NotNull final String tagName) {
|
||||||
|
|
||||||
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
|
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
|
||||||
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
|
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
|
||||||
|
|
||||||
DistributionSetTagAssigmentResult result;
|
DistributionSetTagAssignmentResult result;
|
||||||
final List<DistributionSet> allDSs = new ArrayList<>();
|
final List<DistributionSet> toBeChangedDSs = new ArrayList<>();
|
||||||
for (final DistributionSet set : sets) {
|
for (final DistributionSet set : sets) {
|
||||||
if (set.getTags().add(myTag)) {
|
if (set.getTags().add(myTag)) {
|
||||||
allDSs.add(set);
|
toBeChangedDSs.add(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unassigment case
|
// un-assignment case
|
||||||
if (allDSs.isEmpty()) {
|
if (toBeChangedDSs.isEmpty()) {
|
||||||
for (final DistributionSet set : sets) {
|
for (final DistributionSet set : sets) {
|
||||||
if (set.getTags().remove(myTag)) {
|
if (set.getTags().remove(myTag)) {
|
||||||
allDSs.add(set);
|
toBeChangedDSs.add(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(),
|
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), 0,
|
||||||
Collections.emptyList(), distributionSetRepository.save(allDSs), myTag);
|
toBeChangedDSs.size(), Collections.emptyList(), distributionSetRepository.save(toBeChangedDSs),
|
||||||
|
myTag);
|
||||||
} else {
|
} else {
|
||||||
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0,
|
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), toBeChangedDSs.size(),
|
||||||
distributionSetRepository.save(allDSs), Collections.emptyList(), myTag);
|
0, distributionSetRepository.save(toBeChangedDSs), Collections.emptyList(), myTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResult resultAssignment = result;
|
final DistributionSetTagAssignmentResult resultAssignment = result;
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
||||||
|
|
||||||
// no reason to persist the tag
|
// no reason to persist the tag
|
||||||
@@ -351,6 +349,9 @@ public class DistributionSetManagement {
|
|||||||
public List<DistributionSet> createDistributionSets(@NotNull final Iterable<DistributionSet> distributionSets) {
|
public List<DistributionSet> createDistributionSets(@NotNull final Iterable<DistributionSet> distributionSets) {
|
||||||
for (final DistributionSet ds : distributionSets) {
|
for (final DistributionSet ds : distributionSets) {
|
||||||
prepareDsSave(ds);
|
prepareDsSave(ds);
|
||||||
|
if (ds.getType() == null) {
|
||||||
|
ds.setType(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return distributionSetRepository.save(distributionSets);
|
return distributionSetRepository.save(distributionSets);
|
||||||
}
|
}
|
||||||
@@ -436,7 +437,7 @@ public class DistributionSetManagement {
|
|||||||
* @param spec
|
* @param spec
|
||||||
* of the search
|
* of the search
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* parametsr for paging
|
* parameter for paging
|
||||||
*
|
*
|
||||||
* @return the found {@link SoftwareModuleType}s
|
* @return the found {@link SoftwareModuleType}s
|
||||||
*/
|
*/
|
||||||
@@ -761,7 +762,7 @@ public class DistributionSetManagement {
|
|||||||
if (distributionSetMetadataRepository.exists(metadata.getId())) {
|
if (distributionSetMetadataRepository.exists(metadata.getId())) {
|
||||||
throwMetadataKeyAlreadyExists(metadata.getId().getKey());
|
throwMetadataKeyAlreadyExists(metadata.getId().getKey());
|
||||||
}
|
}
|
||||||
// merge base software module so optLockRevision gets updated and audit
|
// merge base distribution set so optLockRevision gets updated and audit
|
||||||
// log written because
|
// log written because
|
||||||
// modifying metadata is modifying the base distribution set itself for
|
// modifying metadata is modifying the base distribution set itself for
|
||||||
// auditing purposes.
|
// auditing purposes.
|
||||||
@@ -915,7 +916,7 @@ public class DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<DistributionSetType> createDistributionSetTypes(@NotNull final Collection<DistributionSetType> types) {
|
public List<DistributionSetType> createDistributionSetTypes(@NotNull final Collection<DistributionSetType> types) {
|
||||||
return types.stream().map(type -> createDistributionSetType(type)).collect(Collectors.toList());
|
return types.stream().map(this::createDistributionSetType).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1059,7 +1060,7 @@ public class DistributionSetManagement {
|
|||||||
|
|
||||||
afterCommit.afterCommit(() -> {
|
afterCommit.afterCommit(() -> {
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0,
|
final DistributionSetTagAssignmentResult result = new DistributionSetTagAssignmentResult(0, save.size(), 0,
|
||||||
save, Collections.emptyList(), tag);
|
save, Collections.emptyList(), tag);
|
||||||
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
|
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,9 +29,6 @@ import org.springframework.stereotype.Repository;
|
|||||||
* Workaround as spring data does not provide a {@link Slice} based
|
* Workaround as spring data does not provide a {@link Slice} based
|
||||||
* {@link JpaRepository#findAll()}.
|
* {@link JpaRepository#findAll()}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public class NoCountPagingRepository {
|
public class NoCountPagingRepository {
|
||||||
@@ -104,15 +101,6 @@ public class NoCountPagingRepository {
|
|||||||
super(domainClass, em);
|
super(domainClass, em);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.springframework.data.jpa.repository.support.SimpleJpaRepository#
|
|
||||||
* readPage(javax.persistence .TypedQuery,
|
|
||||||
* org.springframework.data.domain.Pageable,
|
|
||||||
* org.springframework.data.jpa.domain.Specification)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Page<T> readPage(final TypedQuery<T> query, final Pageable pageable, final Specification<T> spec) {
|
protected Page<T> readPage(final TypedQuery<T> query, final Pageable pageable, final Specification<T> spec) {
|
||||||
query.setFirstResult(pageable.getOffset());
|
query.setFirstResult(pageable.getOffset());
|
||||||
|
|||||||
@@ -458,11 +458,6 @@ public class ReportManagement {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -471,11 +466,6 @@ public class ReportManagement {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is
|
public boolean equals(final Object obj) { // NOSONAR - as this is
|
||||||
// generated
|
// generated
|
||||||
@@ -499,11 +489,6 @@ public class ReportManagement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DSName [name=" + name + "]";
|
return "DSName [name=" + name + "]";
|
||||||
@@ -523,9 +508,6 @@ public class ReportManagement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return DateTypes.
|
* Return DateTypes.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final class DateTypes implements Serializable {
|
public static final class DateTypes implements Serializable {
|
||||||
/**
|
/**
|
||||||
@@ -585,12 +567,6 @@ public class ReportManagement {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final String DATE_PATTERN = "yyyy-MM";
|
private static final String DATE_PATTERN = "yyyy-MM";
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
|
||||||
* format(java. lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDate format(final String s) {
|
public LocalDate format(final String s) {
|
||||||
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
|
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
|
||||||
@@ -598,23 +574,11 @@ public class ReportManagement {
|
|||||||
return ym.atDay(1);
|
return ym.atDay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
|
||||||
* h2Format()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String h2Format() {
|
public String h2Format() {
|
||||||
return DATE_PATTERN;
|
return DATE_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
|
||||||
* mySqlFormat( )
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String mySqlFormat() {
|
public String mySqlFormat() {
|
||||||
return "%Y-%m";
|
return "%Y-%m";
|
||||||
|
|||||||
@@ -59,11 +59,7 @@ import com.google.common.base.Strings;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Business facade for managing the deployable {@link SoftwareModule}s.
|
* Business facade for managing {@link SoftwareModule}s.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@@ -99,7 +95,7 @@ public class SoftwareManagement {
|
|||||||
private ArtifactManagement artifactManagement;
|
private ArtifactManagement artifactManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates existing {@link SoftwareModule}. Updateable values are
|
* Updates existing {@link SoftwareModule}. Update-able values are
|
||||||
* {@link SoftwareModule#getDescription()}
|
* {@link SoftwareModule#getDescription()}
|
||||||
* {@link SoftwareModule#getVendor()}.
|
* {@link SoftwareModule#getVendor()}.
|
||||||
*
|
*
|
||||||
@@ -119,17 +115,21 @@ public class SoftwareManagement {
|
|||||||
|
|
||||||
final SoftwareModule module = softwareModuleRepository.findOne(sm.getId());
|
final SoftwareModule module = softwareModuleRepository.findOne(sm.getId());
|
||||||
|
|
||||||
|
boolean updated = false;
|
||||||
if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) {
|
if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) {
|
||||||
module.setDescription(sm.getDescription());
|
module.setDescription(sm.getDescription());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
if (null == sm.getVendor() || !sm.getVendor().equals(module.getVendor())) {
|
if (null == sm.getVendor() || !sm.getVendor().equals(module.getVendor())) {
|
||||||
module.setVendor(sm.getVendor());
|
module.setVendor(sm.getVendor());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
return softwareModuleRepository.save(module);
|
|
||||||
|
return updated ? softwareModuleRepository.save(module) : module;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates existing {@link SoftwareModuleType}. Updatable value is
|
* Updates existing {@link SoftwareModuleType}. Update-able value is
|
||||||
* {@link SoftwareModuleType#getDescription()} and
|
* {@link SoftwareModuleType#getDescription()} and
|
||||||
* {@link SoftwareModuleType#getColour()}.
|
* {@link SoftwareModuleType#getColour()}.
|
||||||
*
|
*
|
||||||
@@ -145,13 +145,16 @@ public class SoftwareManagement {
|
|||||||
|
|
||||||
final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
|
final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
|
||||||
|
|
||||||
|
boolean updated = false;
|
||||||
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
|
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
|
||||||
type.setDescription(sm.getDescription());
|
type.setDescription(sm.getDescription());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
if (sm.getColour() != null && !sm.getColour().equals(type.getColour())) {
|
if (sm.getColour() != null && !sm.getColour().equals(type.getColour())) {
|
||||||
type.setColour(sm.getColour());
|
type.setColour(sm.getColour());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
return softwareModuleTypeRepository.save(type);
|
return updated ? softwareModuleTypeRepository.save(type) : type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,13 +265,15 @@ public class SoftwareManagement {
|
|||||||
* of the {@link SoftwareModule}
|
* of the {@link SoftwareModule}
|
||||||
* @param version
|
* @param version
|
||||||
* of the {@link SoftwareModule}
|
* of the {@link SoftwareModule}
|
||||||
* @return the found {@link SoftwareModule}s
|
* @param type
|
||||||
|
* of the {@link SoftwareModule}
|
||||||
|
* @return the found {@link SoftwareModule} or <code>null</code>
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<SoftwareModule> findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
|
public SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
|
||||||
@NotEmpty final String version) {
|
@NotEmpty final String version, @NotNull final SoftwareModuleType type) {
|
||||||
|
|
||||||
return softwareModuleRepository.findByNameAndVersion(name, version);
|
return softwareModuleRepository.findOneByNameAndVersionAndType(name, version, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -491,21 +496,27 @@ public class SoftwareManagement {
|
|||||||
/**
|
/**
|
||||||
* Filter {@link SoftwareModule}s with given
|
* Filter {@link SoftwareModule}s with given
|
||||||
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
||||||
* and {@link SoftwareModule#getType()} that are not marked as deleted.
|
* search text and {@link SoftwareModule#getType()} that are not marked as
|
||||||
|
* deleted and sort them by means of given distribution set related modules
|
||||||
|
* on top of the list.
|
||||||
|
*
|
||||||
|
* After that the modules are sorted by {@link SoftwareModule#getName()} and
|
||||||
|
* {@link SoftwareModule#getVersion()} in ascending order.
|
||||||
*
|
*
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* page parameter
|
* page parameter
|
||||||
* @param orderByDistributionId
|
* @param orderByDistributionId
|
||||||
* the ID of distribution set to be order by
|
* the ID of distribution set to be ordered on top
|
||||||
* @param searchText
|
* @param searchText
|
||||||
* to be filtered as "like" on {@link SoftwareModule#getName()}
|
* filtered as "like" on {@link SoftwareModule#getName()}
|
||||||
* @param type
|
* @param type
|
||||||
* to be filtered as "like" on {@link SoftwareModule#getType()}
|
* filtered as "equal" on {@link SoftwareModule#getType()}
|
||||||
* @return the page of found {@link SoftwareModule}
|
* @return the page of found {@link SoftwareModule}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<CustomSoftwareModule> findSoftwareModuleOrderByDistribution(@NotNull final Pageable pageable,
|
public Slice<CustomSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||||
@NotNull final Long orderByDistributionId, final String searchText, final SoftwareModuleType type) {
|
@NotNull final Pageable pageable, @NotNull final Long orderByDistributionId, final String searchText,
|
||||||
|
final SoftwareModuleType type) {
|
||||||
|
|
||||||
final List<CustomSoftwareModule> resultList = new ArrayList<>();
|
final List<CustomSoftwareModule> resultList = new ArrayList<>();
|
||||||
final int pageSize = pageable.getPageSize();
|
final int pageSize = pageable.getPageSize();
|
||||||
@@ -522,7 +533,7 @@ public class SoftwareManagement {
|
|||||||
assignedRoot, assignedQuery, cb,
|
assignedRoot, assignedQuery, cb,
|
||||||
cb.equal(assignedDsJoin.get(DistributionSet_.id), orderByDistributionId));
|
cb.equal(assignedDsJoin.get(DistributionSet_.id), orderByDistributionId));
|
||||||
// if we have some predicates then add it to the where clause of the
|
// if we have some predicates then add it to the where clause of the
|
||||||
// multiselect
|
// multi select
|
||||||
assignedQuery.where(specPredicate);
|
assignedQuery.where(specPredicate);
|
||||||
assignedQuery.orderBy(cb.asc(assignedRoot.get(SoftwareModule_.name)),
|
assignedQuery.orderBy(cb.asc(assignedRoot.get(SoftwareModule_.name)),
|
||||||
cb.asc(assignedRoot.get(SoftwareModule_.version)));
|
cb.asc(assignedRoot.get(SoftwareModule_.version)));
|
||||||
@@ -546,7 +557,7 @@ public class SoftwareManagement {
|
|||||||
unassignedQuery.distinct(true);
|
unassignedQuery.distinct(true);
|
||||||
final Root<SoftwareModule> unassignedRoot = unassignedQuery.from(SoftwareModule.class);
|
final Root<SoftwareModule> unassignedRoot = unassignedQuery.from(SoftwareModule.class);
|
||||||
|
|
||||||
Predicate[] unassignedSpec = null;
|
Predicate[] unassignedSpec;
|
||||||
if (!assignedSoftwareModules.isEmpty()) {
|
if (!assignedSoftwareModules.isEmpty()) {
|
||||||
unassignedSpec = specificationsToPredicate(buildSpecificationList(searchText, type), unassignedRoot,
|
unassignedSpec = specificationsToPredicate(buildSpecificationList(searchText, type), unassignedRoot,
|
||||||
unassignedQuery, cb, cb.not(unassignedRoot.get(SoftwareModule_.id)
|
unassignedQuery, cb, cb.not(unassignedRoot.get(SoftwareModule_.id)
|
||||||
@@ -709,8 +720,8 @@ public class SoftwareManagement {
|
|||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<SoftwareModuleType> createSoftwareModuleTypes(@NotNull final Collection<SoftwareModuleType> types) {
|
public List<SoftwareModuleType> createSoftwareModuleType(@NotNull final Collection<SoftwareModuleType> types) {
|
||||||
return types.stream().map(type -> createSoftwareModuleType(type)).collect(Collectors.toList());
|
return types.stream().map(this::createSoftwareModuleType).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -826,7 +837,7 @@ public class SoftwareManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) {
|
public SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) {
|
||||||
// check if exists otherwise throw entity not found exception
|
// check if exists otherwise throw entity not found exception
|
||||||
findOne(metadata.getId());
|
findSoftwareModuleMetadata(metadata.getId());
|
||||||
// touch it to update the lock revision because we are modifying the
|
// touch it to update the lock revision because we are modifying the
|
||||||
// software module
|
// software module
|
||||||
// indirectly
|
// indirectly
|
||||||
@@ -884,7 +895,7 @@ public class SoftwareManagement {
|
|||||||
cb) -> cb.and(
|
cb) -> cb.and(
|
||||||
cb.equal(root.get(SoftwareModuleMetadata_.softwareModule)
|
cb.equal(root.get(SoftwareModuleMetadata_.softwareModule)
|
||||||
.get(SoftwareModule_.id), softwareModuleId),
|
.get(SoftwareModule_.id), softwareModuleId),
|
||||||
spec.toPredicate(root, query, cb)),
|
spec.toPredicate(root, query, cb)),
|
||||||
pageable);
|
pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,7 +910,7 @@ public class SoftwareManagement {
|
|||||||
* in case the meta data does not exists for the given key
|
* in case the meta data does not exists for the given key
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public SoftwareModuleMetadata findOne(@NotNull final SwMetadataCompositeKey id) {
|
public SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull final SwMetadataCompositeKey id) {
|
||||||
final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id);
|
final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id);
|
||||||
if (findOne == null) {
|
if (findOne == null) {
|
||||||
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
|
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
|
||||||
|
|||||||
@@ -43,15 +43,19 @@ public interface SoftwareModuleRepository
|
|||||||
Long countByType(SoftwareModuleType type);
|
Long countByType(SoftwareModuleType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves {@link SoftwareModule}s by filtering on name AND version.
|
* Retrieves {@link SoftwareModule} by filtering on name AND version AND
|
||||||
|
* type (which is unique per tenant.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* to be filtered on
|
* to be filtered on
|
||||||
* @param version
|
* @param version
|
||||||
* to be filtered on
|
* to be filtered on
|
||||||
* @return the found {@link SoftwareModule}s with the given name AND verion
|
* @param type
|
||||||
|
* to be filtered on
|
||||||
|
* @return the found {@link SoftwareModule} with the given name AND version
|
||||||
|
* AND type
|
||||||
*/
|
*/
|
||||||
List<SoftwareModule> findByNameAndVersion(String name, String version);
|
SoftwareModule findOneByNameAndVersionAndType(String name, String version, SoftwareModuleType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deletes the {@link SoftwareModule}s with the given IDs.
|
* deletes the {@link SoftwareModule}s with the given IDs.
|
||||||
@@ -81,6 +85,8 @@ public interface SoftwareModuleRepository
|
|||||||
Page<SoftwareModule> findByAssignedTo(Pageable pageable, DistributionSet set);
|
Page<SoftwareModule> findByAssignedTo(Pageable pageable, DistributionSet set);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
* @param set
|
* @param set
|
||||||
* to search for
|
* to search for
|
||||||
* @return all {@link SoftwareModule}s that are assigned to given
|
* @return all {@link SoftwareModule}s that are assigned to given
|
||||||
|
|||||||
@@ -310,8 +310,6 @@ public class SystemManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType createStandardSoftwareDataSetup() {
|
private DistributionSetType createStandardSoftwareDataSetup() {
|
||||||
|
|
||||||
// Edge Controller Linux standard setup
|
|
||||||
final SoftwareModuleType eclApp = softwareModuleTypeRepository.save(new SoftwareModuleType("application",
|
final SoftwareModuleType eclApp = softwareModuleTypeRepository.save(new SoftwareModuleType("application",
|
||||||
"ECL Application", "Edge Controller Linux base application type", 1));
|
"ECL Application", "Edge Controller Linux base application type", 1));
|
||||||
final SoftwareModuleType eclOs = softwareModuleTypeRepository
|
final SoftwareModuleType eclOs = softwareModuleTypeRepository
|
||||||
@@ -341,18 +339,8 @@ public class SystemManagement {
|
|||||||
* default types we need to use the tenant the current tenant which is
|
* default types we need to use the tenant the current tenant which is
|
||||||
* currently created and not the one currently in the {@link TenantAware}.
|
* currently created and not the one currently in the {@link TenantAware}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private class CurrentTenantKeyGenerator implements KeyGenerator {
|
private class CurrentTenantKeyGenerator implements KeyGenerator {
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.springframework.cache.interceptor.KeyGenerator#generate(java.lang
|
|
||||||
* .Object, java.lang.reflect.Method, java.lang.Object[])
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Object generate(final Object target, final Method method, final Object... params) {
|
public Object generate(final Object target, final Method method, final Object... params) {
|
||||||
final String initialTenantCreation = createInitialTenant.get();
|
final String initialTenantCreation = createInitialTenant.get();
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import org.eclipse.hawkbit.repository.model.TargetIdName;
|
|||||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetInfo_;
|
import org.eclipse.hawkbit.repository.model.TargetInfo_;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.repository.model.Target_;
|
import org.eclipse.hawkbit.repository.model.Target_;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||||
@@ -53,7 +53,6 @@ import org.hibernate.validator.constraints.NotEmpty;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.domain.SliceImpl;
|
import org.springframework.data.domain.SliceImpl;
|
||||||
@@ -74,8 +73,6 @@ import com.google.common.eventbus.EventBus;
|
|||||||
/**
|
/**
|
||||||
* Business service facade for managing {@link Target}s.
|
* Business service facade for managing {@link Target}s.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@Validated
|
@Validated
|
||||||
@@ -157,7 +154,7 @@ public class TargetManagement {
|
|||||||
* @return List of found{@link Target}s
|
* @return List of found{@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public List<Target> findTargetsByControllerID(@NotEmpty final Collection<String> controllerIDs) {
|
public List<Target> findTargetByControllerID(@NotEmpty final Collection<String> controllerIDs) {
|
||||||
return targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndAssignedInJoin(controllerIDs));
|
return targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndAssignedInJoin(controllerIDs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,10 +330,10 @@ public class TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
* Retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||||
* details, i.e. NO {@link Target#getTags()} and
|
* details, i.e. NO {@link Target#getTags()} and
|
||||||
* {@link Target#getActiveActions()} possible including the filtering based
|
* {@link Target#getActiveActions()} possible including additional filtering
|
||||||
* on the given {@code spec}.
|
* based on the given {@code spec}.
|
||||||
*
|
*
|
||||||
* @param distributionSetID
|
* @param distributionSetID
|
||||||
* the ID of the {@link DistributionSet}
|
* the ID of the {@link DistributionSet}
|
||||||
@@ -376,7 +373,8 @@ public class TargetManagement {
|
|||||||
/**
|
/**
|
||||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
||||||
* details, i.e. NO {@link Target#getTags()} and
|
* details, i.e. NO {@link Target#getTags()} and
|
||||||
* {@link Target#getActiveActions()} possible.
|
* {@link Target#getActiveActions()} possible including additional filtering
|
||||||
|
* based on the given {@code spec}.
|
||||||
*
|
*
|
||||||
* @param distributionSetId
|
* @param distributionSetId
|
||||||
* the ID of the {@link DistributionSet}
|
* the ID of the {@link DistributionSet}
|
||||||
@@ -492,7 +490,7 @@ public class TargetManagement {
|
|||||||
if (!Strings.isNullOrEmpty(searchText)) {
|
if (!Strings.isNullOrEmpty(searchText)) {
|
||||||
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText));
|
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText));
|
||||||
}
|
}
|
||||||
if (selectTargetWithNoTag || (tagNames != null && tagNames.length > 0)) {
|
if (selectTargetWithNoTag != null && (selectTargetWithNoTag || (tagNames != null && tagNames.length > 0))) {
|
||||||
specList.add(TargetSpecifications.hasTags(tagNames, selectTargetWithNoTag));
|
specList.add(TargetSpecifications.hasTags(tagNames, selectTargetWithNoTag));
|
||||||
}
|
}
|
||||||
return specList;
|
return specList;
|
||||||
@@ -536,7 +534,7 @@ public class TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final List<Target> targets,
|
public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final List<Target> targets,
|
||||||
@NotNull final TargetTag tag) {
|
@NotNull final TargetTag tag) {
|
||||||
return toggleTagAssignment(
|
return toggleTagAssignment(
|
||||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
||||||
@@ -558,7 +556,7 @@ public class TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection<String> targetIds,
|
public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection<String> targetIds,
|
||||||
@NotNull final String tagName) {
|
@NotNull final String tagName) {
|
||||||
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
|
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
|
||||||
final List<Target> alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
|
final List<Target> alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
|
||||||
@@ -568,7 +566,7 @@ public class TargetManagement {
|
|||||||
// all are already assigned -> unassign
|
// all are already assigned -> unassign
|
||||||
if (alreadyAssignedTargets.size() == allTargets.size()) {
|
if (alreadyAssignedTargets.size() == allTargets.size()) {
|
||||||
alreadyAssignedTargets.forEach(target -> target.getTags().remove(tag));
|
alreadyAssignedTargets.forEach(target -> target.getTags().remove(tag));
|
||||||
final TargetTagAssigmentResult result = new TargetTagAssigmentResult(0, 0, alreadyAssignedTargets.size(),
|
final TargetTagAssignmentResult result = new TargetTagAssignmentResult(0, 0, alreadyAssignedTargets.size(),
|
||||||
Collections.emptyList(), alreadyAssignedTargets, tag);
|
Collections.emptyList(), alreadyAssignedTargets, tag);
|
||||||
|
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||||
@@ -578,7 +576,7 @@ public class TargetManagement {
|
|||||||
allTargets.removeAll(alreadyAssignedTargets);
|
allTargets.removeAll(alreadyAssignedTargets);
|
||||||
// some or none are assigned -> assign
|
// some or none are assigned -> assign
|
||||||
allTargets.forEach(target -> target.getTags().add(tag));
|
allTargets.forEach(target -> target.getTags().add(tag));
|
||||||
final TargetTagAssigmentResult result = new TargetTagAssigmentResult(alreadyAssignedTargets.size(),
|
final TargetTagAssignmentResult result = new TargetTagAssignmentResult(alreadyAssignedTargets.size(),
|
||||||
allTargets.size(), 0, targetRepository.save(allTargets), Collections.emptyList(), tag);
|
allTargets.size(), 0, targetRepository.save(allTargets), Collections.emptyList(), tag);
|
||||||
|
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||||
@@ -609,7 +607,7 @@ public class TargetManagement {
|
|||||||
final List<Target> save = targetRepository.save(allTargets);
|
final List<Target> save = targetRepository.save(allTargets);
|
||||||
|
|
||||||
afterCommit.afterCommit(() -> {
|
afterCommit.afterCommit(() -> {
|
||||||
final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, save.size(), 0, save,
|
final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, save.size(), 0, save,
|
||||||
Collections.emptyList(), tag);
|
Collections.emptyList(), tag);
|
||||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
||||||
});
|
});
|
||||||
@@ -622,7 +620,7 @@ public class TargetManagement {
|
|||||||
|
|
||||||
final List<Target> save = targetRepository.save(targets);
|
final List<Target> save = targetRepository.save(targets);
|
||||||
afterCommit.afterCommit(() -> {
|
afterCommit.afterCommit(() -> {
|
||||||
final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, 0, save.size(),
|
final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, 0, save.size(),
|
||||||
Collections.emptyList(), save, tag);
|
Collections.emptyList(), save, tag);
|
||||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
||||||
});
|
});
|
||||||
@@ -812,14 +810,12 @@ public class TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all {@link Target#getControllerId()} for all the given parameters.
|
* Finds all targets for all the given parameters but returns not the full
|
||||||
|
* target but {@link TargetIdName}.
|
||||||
*
|
*
|
||||||
* @param pageRequest
|
* @param pageRequest
|
||||||
* the pageRequest to enhance the query for paging and sorting
|
* the pageRequest to enhance the query for paging and sorting
|
||||||
* @param filterByDistributionId
|
*
|
||||||
* to find targets having the {@link DistributionSet} as
|
|
||||||
* installed or assigned. Set to <code>null</code> in case this
|
|
||||||
* is not required.
|
|
||||||
* @param filterByStatus
|
* @param filterByStatus
|
||||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||||
* <code>null</code> in case this is not required.
|
* <code>null</code> in case this is not required.
|
||||||
@@ -827,28 +823,38 @@ public class TargetManagement {
|
|||||||
* to find targets having the text anywhere in name or
|
* to find targets having the text anywhere in name or
|
||||||
* description. Set <code>null</code> in case this is not
|
* description. Set <code>null</code> in case this is not
|
||||||
* required.
|
* required.
|
||||||
|
* @param installedOrAssignedDistributionSetId
|
||||||
|
* to find targets having the {@link DistributionSet} as
|
||||||
|
* installed or assigned. Set to <code>null</code> in case this
|
||||||
|
* is not required.
|
||||||
* @param filterByTagNames
|
* @param filterByTagNames
|
||||||
* to find targets which are having any one in this tag names.
|
* to find targets which are having any one in this tag names.
|
||||||
* Set <code>null</code> in case this is not required.
|
* Set <code>null</code> in case this is not required.
|
||||||
* @param selectTargetWithNoTag
|
* @param selectTargetWithNoTag
|
||||||
* flag to select targets with no tag assigned
|
* flag to select targets with no tag assigned
|
||||||
*
|
*
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link TargetIdName}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public List<TargetIdName> findAllTargetIdsByFilters(final PageRequest pageRequest,
|
public List<TargetIdName> findAllTargetIdsByFilters(@NotNull final Pageable pageRequest,
|
||||||
final Long filterByDistributionId, final Collection<TargetUpdateStatus> filterByStatus,
|
final Collection<TargetUpdateStatus> filterByStatus, final String filterBySearchText,
|
||||||
final String filterBySearchText, final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
|
final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag,
|
||||||
|
final String... filterByTagNames) {
|
||||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||||
final Root<Target> targetRoot = query.from(Target.class);
|
final Root<Target> targetRoot = query.from(Target.class);
|
||||||
List<Object[]> resultList;
|
List<Object[]> resultList;
|
||||||
|
|
||||||
|
String sortProperty = Target_.id.getName();
|
||||||
|
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
|
||||||
|
sortProperty = pageRequest.getSort().iterator().next().getProperty();
|
||||||
|
}
|
||||||
|
|
||||||
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
||||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
||||||
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
|
||||||
|
|
||||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
||||||
buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId,
|
buildSpecificationList(filterByStatus, filterBySearchText, installedOrAssignedDistributionSetId,
|
||||||
selectTargetWithNoTag, false, filterByTagNames),
|
selectTargetWithNoTag, false, filterByTagNames),
|
||||||
targetRoot, multiselect, cb);
|
targetRoot, multiselect, cb);
|
||||||
|
|
||||||
@@ -864,24 +870,29 @@ public class TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all {@link Target#getControllerId()} for all the given parameter
|
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||||
* {@link TargetFilterQuery}.
|
* and returns not the full target but {@link TargetIdName}.
|
||||||
*
|
*
|
||||||
* @param pageRequest
|
* @param pageRequest
|
||||||
* the pageRequest to enhance the query for paging and sorting
|
* the pageRequest to enhance the query for paging and sorting
|
||||||
* @param targetFilterQuery
|
* @param targetFilterQuery
|
||||||
* {@link TargetFilterQuery}
|
* {@link TargetFilterQuery}
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link TargetIdName}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final PageRequest pageRequest,
|
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final Pageable pageRequest,
|
||||||
@NotNull final TargetFilterQuery targetFilterQuery) {
|
@NotNull final TargetFilterQuery targetFilterQuery) {
|
||||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||||
final Root<Target> targetRoot = query.from(Target.class);
|
final Root<Target> targetRoot = query.from(Target.class);
|
||||||
|
|
||||||
|
String sortProperty = Target_.id.getName();
|
||||||
|
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
|
||||||
|
sortProperty = pageRequest.getSort().iterator().next().getProperty();
|
||||||
|
}
|
||||||
|
|
||||||
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
||||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
||||||
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
|
||||||
|
|
||||||
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
||||||
final List<Specification<Target>> specList = new ArrayList<>();
|
final List<Specification<Target>> specList = new ArrayList<>();
|
||||||
@@ -1074,7 +1085,7 @@ public class TargetManagement {
|
|||||||
return targetRepository.count(specs);
|
return targetRepository.count(specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Object[]> getTargetIdNameResultSet(final PageRequest pageRequest, final CriteriaBuilder cb,
|
private List<Object[]> getTargetIdNameResultSet(final Pageable pageRequest, final CriteriaBuilder cb,
|
||||||
final Root<Target> targetRoot, final CriteriaQuery<Object[]> multiselect) {
|
final Root<Target> targetRoot, final CriteriaQuery<Object[]> multiselect) {
|
||||||
List<Object[]> resultList;
|
List<Object[]> resultList;
|
||||||
if (pageRequest.getSort() != null) {
|
if (pageRequest.getSort() != null) {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
|||||||
* @param configurationKey
|
* @param configurationKey
|
||||||
* the key of the configuration
|
* the key of the configuration
|
||||||
* @return the converted configuration value either from the tenant specific
|
* @return the converted configuration value either from the tenant specific
|
||||||
* configuration stored or from the fallback default values or
|
* configuration stored or from the fall back default values or
|
||||||
* {@code null} in case key has not been configured and not default
|
* {@code null} in case key has not been configured and not default
|
||||||
* value exists
|
* value exists
|
||||||
* @throws TenantConfigurationValidatorException
|
* @throws TenantConfigurationValidatorException
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
/**
|
/**
|
||||||
* The spring-data repository for the entity {@link TenantConfiguration}.
|
* The spring-data repository for the entity {@link TenantConfiguration}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface TenantConfigurationRepository extends BaseEntityRepository<TenantConfiguration, Long> {
|
public interface TenantConfigurationRepository extends BaseEntityRepository<TenantConfiguration, Long> {
|
||||||
@@ -32,11 +29,6 @@ public interface TenantConfigurationRepository extends BaseEntityRepository<Tena
|
|||||||
*/
|
*/
|
||||||
TenantConfiguration findByKey(String configurationKey);
|
TenantConfiguration findByKey(String configurationKey);
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.data.repository.CrudRepository#findAll()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
List<TenantConfiguration> findAll();
|
List<TenantConfiguration> findAll();
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ import org.springframework.stereotype.Service;
|
|||||||
/**
|
/**
|
||||||
* {@link KeyGenerator} for tenant related caches.
|
* {@link KeyGenerator} for tenant related caches.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TenantKeyGenerator implements KeyGenerator {
|
public class TenantKeyGenerator implements KeyGenerator {
|
||||||
@@ -28,13 +25,6 @@ public class TenantKeyGenerator implements KeyGenerator {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TenantAware tenantAware;
|
private TenantAware tenantAware;
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.springframework.cache.interceptor.KeyGenerator#generate(java.lang.
|
|
||||||
* Object, java.lang.reflect.Method, java.lang.Object[])
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Object generate(final Object target, final Method method, final Object... params) {
|
public Object generate(final Object target, final Method method, final Object... params) {
|
||||||
return tenantAware.getCurrentTenant().toUpperCase();
|
return tenantAware.getCurrentTenant().toUpperCase();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
|||||||
@Index(name = "sp_idx_action_prim", columnList = "tenant,id") })
|
@Index(name = "sp_idx_action_prim", columnList = "tenant,id") })
|
||||||
@NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }),
|
@NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }),
|
||||||
@NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"),
|
@NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"),
|
||||||
@NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet") ) ) })
|
@NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet"))) })
|
||||||
@Entity
|
@Entity
|
||||||
public class Action extends TenantAwareBaseEntity implements Comparable<Action> {
|
public class Action extends TenantAwareBaseEntity implements Comparable<Action> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -64,11 +64,11 @@ public class Action extends TenantAwareBaseEntity implements Comparable<Action>
|
|||||||
* the {@link DistributionSet} which should be installed by this action.
|
* the {@link DistributionSet} which should be installed by this action.
|
||||||
*/
|
*/
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds") )
|
@JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds"))
|
||||||
private DistributionSet distributionSet;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target") )
|
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target"))
|
||||||
private Target target;
|
private Target target;
|
||||||
|
|
||||||
@Column(name = "active")
|
@Column(name = "active")
|
||||||
@@ -90,11 +90,11 @@ public class Action extends TenantAwareBaseEntity implements Comparable<Action>
|
|||||||
private List<ActionStatus> actionStatus;
|
private List<ActionStatus> actionStatus;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "rolloutgroup", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup") )
|
@JoinColumn(name = "rolloutgroup", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup"))
|
||||||
private RolloutGroup rolloutGroup;
|
private RolloutGroup rolloutGroup;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "rollout", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout") )
|
@JoinColumn(name = "rollout", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout"))
|
||||||
private Rollout rollout;
|
private Rollout rollout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,55 +127,30 @@ public class Action extends TenantAwareBaseEntity implements Comparable<Action>
|
|||||||
return status == Status.CANCELING || status == Status.CANCELED;
|
return status == Status.CANCELING || status == Status.CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param active
|
|
||||||
* the active to set
|
|
||||||
*/
|
|
||||||
public void setActive(final boolean active) {
|
public void setActive(final boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the status
|
|
||||||
*/
|
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param status
|
|
||||||
* the status to set
|
|
||||||
*/
|
|
||||||
public void setStatus(final Status status) {
|
public void setStatus(final Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the downloadProgressPercent
|
|
||||||
*/
|
|
||||||
public int getDownloadProgressPercent() {
|
public int getDownloadProgressPercent() {
|
||||||
return downloadProgressPercent;
|
return downloadProgressPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param downloadProgressPercent
|
|
||||||
* the downloadProgressPercent to set
|
|
||||||
*/
|
|
||||||
public void setDownloadProgressPercent(final int downloadProgressPercent) {
|
public void setDownloadProgressPercent(final int downloadProgressPercent) {
|
||||||
this.downloadProgressPercent = downloadProgressPercent;
|
this.downloadProgressPercent = downloadProgressPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the active
|
|
||||||
*/
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param actionType
|
|
||||||
* the actionType to set
|
|
||||||
*/
|
|
||||||
public void setActionType(final ActionType actionType) {
|
public void setActionType(final ActionType actionType) {
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
}
|
}
|
||||||
@@ -187,69 +162,38 @@ public class Action extends TenantAwareBaseEntity implements Comparable<Action>
|
|||||||
return actionType;
|
return actionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionStatus
|
|
||||||
*/
|
|
||||||
public List<ActionStatus> getActionStatus() {
|
public List<ActionStatus> getActionStatus() {
|
||||||
return actionStatus;
|
return actionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param target
|
|
||||||
* the target to set
|
|
||||||
*/
|
|
||||||
public void setTarget(final Target target) {
|
public void setTarget(final Target target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the target
|
|
||||||
*/
|
|
||||||
public Target getTarget() {
|
public Target getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the forcedTime
|
|
||||||
*/
|
|
||||||
public long getForcedTime() {
|
public long getForcedTime() {
|
||||||
return forcedTime;
|
return forcedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param forcedTime
|
|
||||||
* the forcedTime to set
|
|
||||||
*/
|
|
||||||
public void setForcedTime(final long forcedTime) {
|
public void setForcedTime(final long forcedTime) {
|
||||||
this.forcedTime = forcedTime;
|
this.forcedTime = forcedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rolloutGroup
|
|
||||||
*/
|
|
||||||
public RolloutGroup getRolloutGroup() {
|
public RolloutGroup getRolloutGroup() {
|
||||||
return rolloutGroup;
|
return rolloutGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rolloutGroup
|
|
||||||
* the rolloutGroup to set
|
|
||||||
*/
|
|
||||||
public void setRolloutGroup(final RolloutGroup rolloutGroup) {
|
public void setRolloutGroup(final RolloutGroup rolloutGroup) {
|
||||||
this.rolloutGroup = rolloutGroup;
|
this.rolloutGroup = rolloutGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rollout
|
|
||||||
*/
|
|
||||||
public Rollout getRollout() {
|
public Rollout getRollout() {
|
||||||
return rollout;
|
return rollout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rollout
|
|
||||||
* the rollout to set
|
|
||||||
*/
|
|
||||||
public void setRollout(final Rollout rollout) {
|
public void setRollout(final Rollout rollout) {
|
||||||
this.rollout = rollout;
|
this.rollout = rollout;
|
||||||
}
|
}
|
||||||
@@ -305,63 +249,28 @@ public class Action extends TenantAwareBaseEntity implements Comparable<Action>
|
|||||||
return actionType == ActionType.FORCED;
|
return actionType == ActionType.FORCED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Action [distributionSet=" + distributionSet + ", getId()=" + getId() + "]";
|
return "Action [distributionSet=" + distributionSet + ", getId()=" + getId() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((actionType == null) ? 0 : actionType.hashCode());
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
result = prime * result + (active ? 1231 : 1237);
|
|
||||||
result = prime * result + (int) (forcedTime ^ (forcedTime >>> 32));
|
|
||||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
|
||||||
result = prime * result + (isHitAutoForceTime(System.currentTimeMillis()) ? 1231 : 1237);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) {
|
||||||
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof Action)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Action other = (Action) obj;
|
|
||||||
if (actionType != other.actionType) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (active != other.active) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (forcedTime != other.forcedTime) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (status != other.status) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,9 +333,6 @@ public class Action extends TenantAwareBaseEntity implements Comparable<Action>
|
|||||||
/**
|
/**
|
||||||
* The action type for this action relation.
|
* The action type for this action relation.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum ActionType {
|
public enum ActionType {
|
||||||
FORCED, SOFT, TIMEFORCED;
|
FORCED, SOFT, TIMEFORCED;
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ import com.google.common.base.Splitter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity to store the status for a specific action.
|
* Entity to store the status for a specific action.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Table(name = "sp_action_status", indexes = { @Index(name = "sp_idx_action_status_01", columnList = "tenant,action"),
|
@Table(name = "sp_action_status", indexes = { @Index(name = "sp_idx_action_status_01", columnList = "tenant,action"),
|
||||||
@Index(name = "sp_idx_action_status_02", columnList = "tenant,action,status"),
|
@Index(name = "sp_idx_action_status_02", columnList = "tenant,action,status"),
|
||||||
@@ -42,10 +39,6 @@ import com.google.common.base.Splitter;
|
|||||||
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
||||||
@Entity
|
@Entity
|
||||||
public class ActionStatus extends TenantAwareBaseEntity {
|
public class ActionStatus extends TenantAwareBaseEntity {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "target_occurred_at")
|
@Column(name = "target_occurred_at")
|
||||||
@@ -67,7 +60,7 @@ public class ActionStatus extends TenantAwareBaseEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ActionStatus} object.
|
* Creates a new {@link ActionStatus} object.
|
||||||
*
|
*
|
||||||
* @param action
|
* @param action
|
||||||
* the action for this action status
|
* the action for this action status
|
||||||
* @param status
|
* @param status
|
||||||
@@ -83,7 +76,7 @@ public class ActionStatus extends TenantAwareBaseEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ActionStatus} object.
|
* Creates a new {@link ActionStatus} object.
|
||||||
*
|
*
|
||||||
* @param action
|
* @param action
|
||||||
* the action for this action status
|
* the action for this action status
|
||||||
* @param status
|
* @param status
|
||||||
@@ -146,4 +139,25 @@ public class ActionStatus extends TenantAwareBaseEntity {
|
|||||||
public void setStatus(final Status status) {
|
public void setStatus(final Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof ActionStatus)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
|
|||||||
* Custom JPA Model for querying {@link Action} include the count of the
|
* Custom JPA Model for querying {@link Action} include the count of the
|
||||||
* action's {@link ActionStatus}.
|
* action's {@link ActionStatus}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ActionWithStatusCount {
|
public class ActionWithStatusCount {
|
||||||
private final Long actionStatusCount;
|
private final Long actionStatusCount;
|
||||||
@@ -37,7 +34,7 @@ public class ActionWithStatusCount {
|
|||||||
/**
|
/**
|
||||||
* JPA constructor, the parameter are the result set columns of the custom
|
* JPA constructor, the parameter are the result set columns of the custom
|
||||||
* query.
|
* query.
|
||||||
*
|
*
|
||||||
* @param actionId
|
* @param actionId
|
||||||
* the ID of the action
|
* the ID of the action
|
||||||
* @param actionType
|
* @param actionType
|
||||||
@@ -70,9 +67,9 @@ public class ActionWithStatusCount {
|
|||||||
final String rolloutName) {
|
final String rolloutName) {
|
||||||
this.actionId = actionId;
|
this.actionId = actionId;
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
this.actionActive = active;
|
actionActive = active;
|
||||||
this.actionForceTime = forcedTime;
|
actionForceTime = forcedTime;
|
||||||
this.actionStatus = status;
|
actionStatus = status;
|
||||||
this.actionCreatedAt = actionCreatedAt;
|
this.actionCreatedAt = actionCreatedAt;
|
||||||
this.actionLastModifiedAt = actionLastModifiedAt;
|
this.actionLastModifiedAt = actionLastModifiedAt;
|
||||||
this.dsId = dsId;
|
this.dsId = dsId;
|
||||||
@@ -81,101 +78,62 @@ public class ActionWithStatusCount {
|
|||||||
this.actionStatusCount = actionStatusCount;
|
this.actionStatusCount = actionStatusCount;
|
||||||
this.rolloutName = rolloutName;
|
this.rolloutName = rolloutName;
|
||||||
|
|
||||||
this.action = new Action();
|
action = new Action();
|
||||||
this.action.setActionType(actionType);
|
action.setActionType(actionType);
|
||||||
this.action.setActive(actionActive);
|
action.setActive(actionActive);
|
||||||
this.action.setForcedTime(actionForceTime);
|
action.setForcedTime(actionForceTime);
|
||||||
this.action.setStatus(actionStatus);
|
action.setStatus(actionStatus);
|
||||||
this.action.setId(actionId);
|
action.setId(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the action
|
|
||||||
*/
|
|
||||||
public Action getAction() {
|
public Action getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionId
|
|
||||||
*/
|
|
||||||
public Long getActionId() {
|
public Long getActionId() {
|
||||||
return actionId;
|
return actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionType
|
|
||||||
*/
|
|
||||||
public ActionType getActionType() {
|
public ActionType getActionType() {
|
||||||
return actionType;
|
return actionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionActive
|
|
||||||
*/
|
|
||||||
public boolean isActionActive() {
|
public boolean isActionActive() {
|
||||||
return actionActive;
|
return actionActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionForceTime
|
|
||||||
*/
|
|
||||||
public long getActionForceTime() {
|
public long getActionForceTime() {
|
||||||
return actionForceTime;
|
return actionForceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionStatus
|
|
||||||
*/
|
|
||||||
public Status getActionStatus() {
|
public Status getActionStatus() {
|
||||||
return actionStatus;
|
return actionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionCreatedAt
|
|
||||||
*/
|
|
||||||
public Long getActionCreatedAt() {
|
public Long getActionCreatedAt() {
|
||||||
return actionCreatedAt;
|
return actionCreatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionLastModifiedAt
|
|
||||||
*/
|
|
||||||
public Long getActionLastModifiedAt() {
|
public Long getActionLastModifiedAt() {
|
||||||
return actionLastModifiedAt;
|
return actionLastModifiedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsId
|
|
||||||
*/
|
|
||||||
public Long getDsId() {
|
public Long getDsId() {
|
||||||
return dsId;
|
return dsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsName
|
|
||||||
*/
|
|
||||||
public String getDsName() {
|
public String getDsName() {
|
||||||
return dsName;
|
return dsName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsVersion
|
|
||||||
*/
|
|
||||||
public String getDsVersion() {
|
public String getDsVersion() {
|
||||||
return dsVersion;
|
return dsVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionStatusCount
|
|
||||||
*/
|
|
||||||
public Long getActionStatusCount() {
|
public Long getActionStatusCount() {
|
||||||
return actionStatusCount;
|
return actionStatusCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rolloutName
|
|
||||||
*/
|
|
||||||
public String getRolloutName() {
|
public String getRolloutName() {
|
||||||
return rolloutName;
|
return rolloutName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,7 @@ import javax.persistence.MappedSuperclass;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tenant specific locally stored artifact representation that is used by
|
* Tenant specific locally stored artifact representation that is used by
|
||||||
* {@link SoftwareModule} .
|
* {@link SoftwareModule}.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class Artifact extends TenantAwareBaseEntity {
|
public abstract class Artifact extends TenantAwareBaseEntity {
|
||||||
@@ -34,49 +30,47 @@ public abstract class Artifact extends TenantAwareBaseEntity {
|
|||||||
|
|
||||||
public abstract SoftwareModule getSoftwareModule();
|
public abstract SoftwareModule getSoftwareModule();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the md5Hash
|
|
||||||
*/
|
|
||||||
public String getMd5Hash() {
|
public String getMd5Hash() {
|
||||||
return md5Hash;
|
return md5Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the sha1Hash
|
|
||||||
*/
|
|
||||||
public String getSha1Hash() {
|
public String getSha1Hash() {
|
||||||
return sha1Hash;
|
return sha1Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param md5Hash
|
|
||||||
* the md5Hash to set
|
|
||||||
*/
|
|
||||||
public void setMd5Hash(final String md5Hash) {
|
public void setMd5Hash(final String md5Hash) {
|
||||||
this.md5Hash = md5Hash;
|
this.md5Hash = md5Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param sha1Hash
|
|
||||||
* the sha1Hash to set
|
|
||||||
*/
|
|
||||||
public void setSha1Hash(final String sha1Hash) {
|
public void setSha1Hash(final String sha1Hash) {
|
||||||
this.sha1Hash = sha1Hash;
|
this.sha1Hash = sha1Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the size
|
|
||||||
*/
|
|
||||||
public Long getSize() {
|
public Long getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param size
|
|
||||||
* the size to set
|
|
||||||
*/
|
|
||||||
public void setSize(final Long size) {
|
public void setSize(final Long size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof Artifact)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.repository.model;
|
package org.eclipse.hawkbit.repository.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic assigment result bean.
|
* Generic assignment result bean.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AssignmentResult {
|
public class AssignmentResult {
|
||||||
@@ -36,23 +33,14 @@ public class AssignmentResult {
|
|||||||
total = assigned + alreadyAssigned;
|
total = assigned + alreadyAssigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assignedTargets
|
|
||||||
*/
|
|
||||||
public int getAssigned() {
|
public int getAssigned() {
|
||||||
return assigned;
|
return assigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the total
|
|
||||||
*/
|
|
||||||
public int getTotal() {
|
public int getTotal() {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the alreadyAssigned
|
|
||||||
*/
|
|
||||||
public int getAlreadyAssigned() {
|
public int getAlreadyAssigned() {
|
||||||
return alreadyAssigned;
|
return alreadyAssigned;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,13 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defined equals/hashcode strategy for the repository in general is that an
|
||||||
|
* entity is equal if it has the same {@link #getId()} and
|
||||||
|
* {@link #getOptLockRevision()} and class.
|
||||||
|
*
|
||||||
|
* @see java.lang.Object#hashCode()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated code
|
public int hashCode() { // NOSONAR - as this is generated code
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -131,6 +138,13 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defined equals/hashcode strategy for the repository in general is that an
|
||||||
|
* entity is equal if it has the same {@link #getId()} and
|
||||||
|
* {@link #getOptLockRevision()} and class.
|
||||||
|
*
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
// code
|
// code
|
||||||
@@ -140,7 +154,7 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof BaseEntity)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BaseEntity other = (BaseEntity) obj;
|
final BaseEntity other = (BaseEntity) obj;
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* Use to display software modules for the selected distribution.
|
* Use to display software modules for the selected distribution.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CustomSoftwareModule implements Serializable {
|
public class CustomSoftwareModule implements Serializable {
|
||||||
|
|
||||||
@@ -39,17 +36,51 @@ public class CustomSoftwareModule implements Serializable {
|
|||||||
this.assigned = assigned;
|
this.assigned = assigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the softwareModule
|
|
||||||
*/
|
|
||||||
public SoftwareModule getSoftwareModule() {
|
public SoftwareModule getSoftwareModule() {
|
||||||
return softwareModule;
|
return softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assigned
|
|
||||||
*/
|
|
||||||
public boolean isAssigned() {
|
public boolean isAssigned() {
|
||||||
return assigned;
|
return assigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CustomSoftwareModule [softwareModule=" + softwareModule + ", assigned=" + assigned + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (assigned ? 1231 : 1237);
|
||||||
|
result = prime * result + (softwareModule == null ? 0 : softwareModule.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof CustomSoftwareModule)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final CustomSoftwareModule other = (CustomSoftwareModule) obj;
|
||||||
|
if (assigned != other.assigned) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (softwareModule == null) {
|
||||||
|
if (other.softwareModule != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!softwareModule.equals(other.softwareModule)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,6 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
|||||||
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
||||||
@@ -67,14 +63,14 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
|
|
||||||
@ManyToMany(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
|
@ManyToMany(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "sp_ds_module", joinColumns = {
|
@JoinTable(name = "sp_ds_module", joinColumns = {
|
||||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds") ) }, inverseJoinColumns = {
|
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) }, inverseJoinColumns = {
|
||||||
@JoinColumn(name = "module_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module") ) })
|
@JoinColumn(name = "module_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
||||||
private final Set<SoftwareModule> modules = new HashSet<>();
|
private final Set<SoftwareModule> modules = new HashSet<>();
|
||||||
|
|
||||||
@ManyToMany(targetEntity = DistributionSetTag.class)
|
@ManyToMany(targetEntity = DistributionSetTag.class)
|
||||||
@JoinTable(name = "sp_ds_dstag", joinColumns = {
|
@JoinTable(name = "sp_ds_dstag", joinColumns = {
|
||||||
@JoinColumn(name = "ds", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds") ) }, inverseJoinColumns = {
|
@JoinColumn(name = "ds", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds")) }, inverseJoinColumns = {
|
||||||
@JoinColumn(name = "TAG", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag") ) })
|
@JoinColumn(name = "TAG", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) })
|
||||||
private Set<DistributionSetTag> tags = new HashSet<>();
|
private Set<DistributionSetTag> tags = new HashSet<>();
|
||||||
|
|
||||||
@Column(name = "deleted")
|
@Column(name = "deleted")
|
||||||
@@ -95,7 +91,7 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
private final List<DistributionSetMetadata> metadata = new ArrayList<>();
|
private final List<DistributionSetMetadata> metadata = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "ds_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds") )
|
@JoinColumn(name = "ds_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds"))
|
||||||
private DistributionSetType type;
|
private DistributionSetType type;
|
||||||
|
|
||||||
@Column(name = "complete")
|
@Column(name = "complete")
|
||||||
@@ -130,39 +126,30 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
if (moduleList != null) {
|
if (moduleList != null) {
|
||||||
moduleList.forEach(this::addModule);
|
moduleList.forEach(this::addModule);
|
||||||
}
|
}
|
||||||
complete = type.checkComplete(this);
|
if (this.type != null) {
|
||||||
|
complete = this.type.checkComplete(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<DistributionSetTag> getTags() {
|
public Set<DistributionSetTag> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the deleted
|
|
||||||
*/
|
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the metadata
|
* @return immutable list of meta data elements.
|
||||||
*/
|
*/
|
||||||
public List<DistributionSetMetadata> getMetadata() {
|
public List<DistributionSetMetadata> getMetadata() {
|
||||||
return metadata;
|
return Collections.unmodifiableList(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actions
|
|
||||||
*/
|
|
||||||
public List<Action> getActions() {
|
public List<Action> getActions() {
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -171,16 +158,8 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -195,10 +174,6 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return requiredMigrationStep;
|
return requiredMigrationStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param deleted
|
|
||||||
* the deleted to set
|
|
||||||
*/
|
|
||||||
public DistributionSet setDeleted(final boolean deleted) {
|
public DistributionSet setDeleted(final boolean deleted) {
|
||||||
this.deleted = deleted;
|
this.deleted = deleted;
|
||||||
return this;
|
return this;
|
||||||
@@ -209,10 +184,6 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tags
|
|
||||||
* the tags to set
|
|
||||||
*/
|
|
||||||
public DistributionSet setTags(final Set<DistributionSetTag> tags) {
|
public DistributionSet setTags(final Set<DistributionSetTag> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
return this;
|
return this;
|
||||||
@@ -232,11 +203,6 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return installedAtTargets;
|
return installedAtTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
|
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
|
||||||
@@ -322,7 +288,7 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
* Searches through modules for the given type.
|
* Searches through modules for the given type.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* to seach for
|
* to search for
|
||||||
* @return SoftwareModule of given type or <code>null</code> if not in the
|
* @return SoftwareModule of given type or <code>null</code> if not in the
|
||||||
* list.
|
* list.
|
||||||
*/
|
*/
|
||||||
@@ -337,26 +303,15 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the type
|
|
||||||
*/
|
|
||||||
public DistributionSetType getType() {
|
public DistributionSetType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param type
|
|
||||||
* the type to set
|
|
||||||
*/
|
|
||||||
public void setType(final DistributionSetType type) {
|
public void setType(final DistributionSetType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the complete
|
|
||||||
*/
|
|
||||||
public boolean isComplete() {
|
public boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import java.io.Serializable;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DistributionSetIdName implements Serializable {
|
public class DistributionSetIdName implements Serializable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
@@ -39,9 +36,6 @@ public class DistributionSetIdName implements Serializable {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -50,40 +44,27 @@ public class DistributionSetIdName implements Serializable {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof DistributionSetIdName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final DistributionSetIdName other = (DistributionSetIdName) obj;
|
final DistributionSetIdName other = (DistributionSetIdName) obj;
|
||||||
@@ -97,11 +78,6 @@ public class DistributionSetIdName implements Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// only return the ID because it's used in vaadin for setting the item
|
// only return the ID because it's used in vaadin for setting the item
|
||||||
|
|||||||
@@ -23,20 +23,13 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata for {@link DistributionSet}.
|
* Meta data for {@link DistributionSet}.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@IdClass(DsMetadataCompositeKey.class)
|
@IdClass(DsMetadataCompositeKey.class)
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_ds_metadata")
|
@Table(name = "sp_ds_metadata")
|
||||||
public class DistributionSetMetadata implements Serializable {
|
public class DistributionSetMetadata implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -49,11 +42,11 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds") )
|
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds"))
|
||||||
private DistributionSet distributionSet;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
public DistributionSetMetadata() {
|
public DistributionSetMetadata() {
|
||||||
|
// Default constructor for JPA.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,49 +66,66 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
return new DsMetadataCompositeKey(distributionSet, key);
|
return new DsMetadataCompositeKey(distributionSet, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the key
|
|
||||||
*/
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param key
|
|
||||||
* the key to set
|
|
||||||
*/
|
|
||||||
public void setKey(final String key) {
|
public void setKey(final String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param distributionSet
|
|
||||||
* the distributionSet to set
|
|
||||||
*/
|
|
||||||
public void setDistributionSet(final DistributionSet distributionSet) {
|
public void setDistributionSet(final DistributionSet distributionSet) {
|
||||||
this.distributionSet = distributionSet;
|
this.distributionSet = distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the value
|
|
||||||
*/
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param value
|
|
||||||
* the value to set
|
|
||||||
*/
|
|
||||||
public void setValue(final String value) {
|
public void setValue(final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the distributionSet
|
|
||||||
*/
|
|
||||||
public DistributionSet getDistributionSet() {
|
public DistributionSet getDistributionSet() {
|
||||||
return distributionSet;
|
return distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (distributionSet == null ? 0 : distributionSet.hashCode());
|
||||||
|
result = prime * result + (key == null ? 0 : key.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof DistributionSetMetadata)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final DistributionSetMetadata other = (DistributionSetMetadata) obj;
|
||||||
|
if (distributionSet == null) {
|
||||||
|
if (other.distributionSet != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!distributionSet.equals(other.distributionSet)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (key == null) {
|
||||||
|
if (other.key != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!key.equals(other.key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,11 @@ import javax.persistence.UniqueConstraint;
|
|||||||
* A {@link DistributionSetTag} is used to describe DistributionSet attributes
|
* A {@link DistributionSetTag} is used to describe DistributionSet attributes
|
||||||
* and use them also for filtering the DistributionSet list.
|
* and use them also for filtering the DistributionSet list.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distributionset_tag", indexes = {
|
@Table(name = "sp_distributionset_tag", indexes = {
|
||||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
"name", "tenant" }, name = "uk_ds_tag") )
|
"name", "tenant" }, name = "uk_ds_tag"))
|
||||||
public class DistributionSetTag extends Tag {
|
public class DistributionSetTag extends Tag {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -69,11 +64,6 @@ public class DistributionSetTag extends Tag {
|
|||||||
return assignedToDistributionSet;
|
return assignedToDistributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -82,16 +72,8 @@ public class DistributionSetTag extends Tag {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ package org.eclipse.hawkbit.repository.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result object for {@link DistributionSetTag} assigments.
|
* Result object for {@link DistributionSetTag} assignments.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DistributionSetTagAssigmentResult extends AssignmentResult {
|
public class DistributionSetTagAssignmentResult extends AssignmentResult {
|
||||||
|
|
||||||
private final int unassigned;
|
private final int unassigned;
|
||||||
private final List<DistributionSet> assignedDs;
|
private final List<DistributionSet> assignedDs;
|
||||||
@@ -37,7 +37,7 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
|
|||||||
* @param distributionSetTag
|
* @param distributionSetTag
|
||||||
* the assigned or unassigned tag
|
* the assigned or unassigned tag
|
||||||
*/
|
*/
|
||||||
public DistributionSetTagAssigmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
public DistributionSetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
||||||
final List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
|
final List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
|
||||||
final DistributionSetTag distributionSetTag) {
|
final DistributionSetTag distributionSetTag) {
|
||||||
super(assigned, alreadyAssigned);
|
super(assigned, alreadyAssigned);
|
||||||
@@ -47,30 +47,18 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
|
|||||||
this.distributionSetTag = distributionSetTag;
|
this.distributionSetTag = distributionSetTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the unassigned
|
|
||||||
*/
|
|
||||||
public int getUnassigned() {
|
public int getUnassigned() {
|
||||||
return unassigned;
|
return unassigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the distributionSetTag
|
|
||||||
*/
|
|
||||||
public DistributionSetTag getDistributionSetTag() {
|
public DistributionSetTag getDistributionSetTag() {
|
||||||
return distributionSetTag;
|
return distributionSetTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assignedDs
|
|
||||||
*/
|
|
||||||
public List<DistributionSet> getAssignedDs() {
|
public List<DistributionSet> getAssignedDs() {
|
||||||
return assignedDs;
|
return assignedDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the unassignedDs
|
|
||||||
*/
|
|
||||||
public List<DistributionSet> getUnassignedDs() {
|
public List<DistributionSet> getUnassignedDs() {
|
||||||
return unassignedDs;
|
return unassignedDs;
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,6 @@ import javax.persistence.UniqueConstraint;
|
|||||||
* A distribution set type defines which software module types can or have to be
|
* A distribution set type defines which software module types can or have to be
|
||||||
* {@link DistributionSet}.
|
* {@link DistributionSet}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distribution_set_type", indexes = {
|
@Table(name = "sp_distribution_set_type", indexes = {
|
||||||
@@ -38,10 +35,6 @@ import javax.persistence.UniqueConstraint;
|
|||||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_dst_name"),
|
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_dst_name"),
|
||||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_dst_key") })
|
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_dst_key") })
|
||||||
public class DistributionSetType extends NamedEntity {
|
public class DistributionSetType extends NamedEntity {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@OneToMany(targetEntity = DistributionSetTypeElement.class, cascade = {
|
@OneToMany(targetEntity = DistributionSetTypeElement.class, cascade = {
|
||||||
@@ -59,7 +52,7 @@ public class DistributionSetType extends NamedEntity {
|
|||||||
private boolean deleted = false;
|
private boolean deleted = false;
|
||||||
|
|
||||||
public DistributionSetType() {
|
public DistributionSetType() {
|
||||||
// default public constructor
|
// default public constructor for JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,7 +84,7 @@ public class DistributionSetType extends NamedEntity {
|
|||||||
public DistributionSetType(final String key, final String name, final String description, final String color) {
|
public DistributionSetType(final String key, final String name, final String description, final String color) {
|
||||||
super(name, description);
|
super(name, description);
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.colour = color;
|
colour = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,17 +249,10 @@ public class DistributionSetType extends NamedEntity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the key
|
|
||||||
*/
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param key
|
|
||||||
* the key to set
|
|
||||||
*/
|
|
||||||
public void setKey(final String key) {
|
public void setKey(final String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
@@ -282,19 +268,10 @@ public class DistributionSetType extends NamedEntity {
|
|||||||
.containsAll(getMandatoryModuleTypes());
|
.containsAll(getMandatoryModuleTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the DistributionSet type color
|
|
||||||
*/
|
|
||||||
public String getColour() {
|
public String getColour() {
|
||||||
return colour;
|
return colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param colour
|
|
||||||
* the col
|
|
||||||
*/
|
|
||||||
public void setColour(final String colour) {
|
public void setColour(final String colour) {
|
||||||
this.colour = colour;
|
this.colour = colour;
|
||||||
}
|
}
|
||||||
@@ -303,14 +280,29 @@ public class DistributionSetType extends NamedEntity {
|
|||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DistributionSetType [key=" + key + ", isDeleted()=" + isDeleted() + ", getId()=" + getId() + "]";
|
return "DistributionSetType [key=" + key + ", isDeleted()=" + isDeleted() + ", getId()=" + getId() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof DistributionSetType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,10 @@ import javax.persistence.Table;
|
|||||||
* Relation element between a {@link DistributionSetType} and its
|
* Relation element between a {@link DistributionSetType} and its
|
||||||
* {@link SoftwareModuleType} elements.
|
* {@link SoftwareModuleType} elements.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_ds_type_element")
|
@Table(name = "sp_ds_type_element")
|
||||||
public class DistributionSetTypeElement implements Serializable {
|
public class DistributionSetTypeElement implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@EmbeddedId
|
@EmbeddedId
|
||||||
@@ -46,18 +39,16 @@ public class DistributionSetTypeElement implements Serializable {
|
|||||||
|
|
||||||
@MapsId("dsType")
|
@MapsId("dsType")
|
||||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "distribution_set_type", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_dstype") )
|
@JoinColumn(name = "distribution_set_type", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_dstype"))
|
||||||
private DistributionSetType dsType;
|
private DistributionSetType dsType;
|
||||||
|
|
||||||
@MapsId("smType")
|
@MapsId("smType")
|
||||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "software_module_type", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_smtype") )
|
@JoinColumn(name = "software_module_type", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_smtype"))
|
||||||
private SoftwareModuleType smType;
|
private SoftwareModuleType smType;
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
public DistributionSetTypeElement() {
|
public DistributionSetTypeElement() {
|
||||||
|
// Default constructor for JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,38 +65,30 @@ public class DistributionSetTypeElement implements Serializable {
|
|||||||
public DistributionSetTypeElement(final DistributionSetType dsType, final SoftwareModuleType smType,
|
public DistributionSetTypeElement(final DistributionSetType dsType, final SoftwareModuleType smType,
|
||||||
final boolean mandatory) {
|
final boolean mandatory) {
|
||||||
super();
|
super();
|
||||||
this.key = new DistributionSetTypeElementCompositeKey(dsType, smType);
|
key = new DistributionSetTypeElementCompositeKey(dsType, smType);
|
||||||
this.dsType = dsType;
|
this.dsType = dsType;
|
||||||
this.smType = smType;
|
this.smType = smType;
|
||||||
this.mandatory = mandatory;
|
this.mandatory = mandatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the mandatory
|
|
||||||
*/
|
|
||||||
public boolean isMandatory() {
|
public boolean isMandatory() {
|
||||||
return mandatory;
|
return mandatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsType
|
|
||||||
*/
|
|
||||||
public DistributionSetType getDsType() {
|
public DistributionSetType getDsType() {
|
||||||
return dsType;
|
return dsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the smType
|
|
||||||
*/
|
|
||||||
public SoftwareModuleType getSmType() {
|
public SoftwareModuleType getSmType() {
|
||||||
return smType;
|
return smType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the key
|
|
||||||
*/
|
|
||||||
public DistributionSetTypeElementCompositeKey getKey() {
|
public DistributionSetTypeElementCompositeKey getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DistributionSetTypeElement [mandatory=" + mandatory + ", dsType=" + dsType + ", smType=" + smType + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,17 +15,9 @@ import javax.persistence.Embeddable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Composite key for {@link DistributionSetTypeElement}.
|
* Composite key for {@link DistributionSetTypeElement}.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class DistributionSetTypeElementCompositeKey implements Serializable {
|
public class DistributionSetTypeElementCompositeKey implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "distribution_set_type", nullable = false)
|
@Column(name = "distribution_set_type", nullable = false)
|
||||||
@@ -54,34 +46,19 @@ public class DistributionSetTypeElementCompositeKey implements Serializable {
|
|||||||
this.smType = smType.getId();
|
this.smType = smType.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsType
|
|
||||||
*/
|
|
||||||
public Long getDsType() {
|
public Long getDsType() {
|
||||||
return dsType;
|
return dsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param dsType
|
|
||||||
* the dsType to set
|
|
||||||
*/
|
|
||||||
public void setDsType(final Long dsType) {
|
public void setDsType(final Long dsType) {
|
||||||
this.dsType = dsType;
|
this.dsType = dsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the smType
|
|
||||||
*/
|
|
||||||
public Long getSmType() {
|
public Long getSmType() {
|
||||||
return smType;
|
return smType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param smType
|
|
||||||
* the smType to set
|
|
||||||
*/
|
|
||||||
public void setSmType(final Long smType) {
|
public void setSmType(final Long smType) {
|
||||||
this.smType = smType;
|
this.smType = smType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,24 +13,17 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* The DistributionSet Metadata composite key which contains the meta data key
|
* The DistributionSet Metadata composite key which contains the meta data key
|
||||||
* and the ID of the DistributionSet itself.
|
* and the ID of the DistributionSet itself.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class DsMetadataCompositeKey implements Serializable {
|
public final class DsMetadataCompositeKey implements Serializable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
private Long distributionSet;
|
private Long distributionSet;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public DsMetadataCompositeKey() {
|
public DsMetadataCompositeKey() {
|
||||||
|
// Default constructor for JPA.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,55 +37,31 @@ public final class DsMetadataCompositeKey implements Serializable {
|
|||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the key
|
|
||||||
*/
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param key
|
|
||||||
* the key to set
|
|
||||||
*/
|
|
||||||
public void setKey(final String key) {
|
public void setKey(final String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the distributionSet
|
|
||||||
*/
|
|
||||||
public Long getDistributionSet() {
|
public Long getDistributionSet() {
|
||||||
return distributionSet;
|
return distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param distributionSet
|
|
||||||
* the distributionSet to set
|
|
||||||
*/
|
|
||||||
public void setDistributionSet(final Long distributionSet) {
|
public void setDistributionSet(final Long distributionSet) {
|
||||||
this.distributionSet = distributionSet;
|
this.distributionSet = distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((distributionSet == null) ? 0 : distributionSet.hashCode());
|
result = prime * result + (distributionSet == null ? 0 : distributionSet.hashCode());
|
||||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
result = prime * result + (key == null ? 0 : key.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
// code
|
// code
|
||||||
|
|||||||
@@ -22,12 +22,9 @@ import javax.persistence.Table;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* External artifact representation with all the necessray informattion to
|
* External artifact representation with all the necessary information to
|
||||||
* generate an artifact {@link URL} at runtime.
|
* generate an artifact {@link URL} at runtime.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Table(name = "sp_external_artifact", indexes = {
|
@Table(name = "sp_external_artifact", indexes = {
|
||||||
@Index(name = "sp_idx_external_artifact_prim", columnList = "id,tenant") })
|
@Index(name = "sp_idx_external_artifact_prim", columnList = "id,tenant") })
|
||||||
@@ -36,7 +33,7 @@ public class ExternalArtifact extends Artifact {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "provider", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_art_to_ext_provider") )
|
@JoinColumn(name = "provider", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_art_to_ext_provider"))
|
||||||
private ExternalArtifactProvider externalArtifactProvider;
|
private ExternalArtifactProvider externalArtifactProvider;
|
||||||
|
|
||||||
@Column(name = "url_suffix", length = 512)
|
@Column(name = "url_suffix", length = 512)
|
||||||
@@ -44,7 +41,7 @@ public class ExternalArtifact extends Artifact {
|
|||||||
|
|
||||||
// CascadeType.PERSIST as we register ourself at the BSM
|
// CascadeType.PERSIST as we register ourself at the BSM
|
||||||
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST })
|
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST })
|
||||||
@JoinColumn(name = "software_module", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_external_assigned_sm") )
|
@JoinColumn(name = "software_module", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_external_assigned_sm"))
|
||||||
private SoftwareModule softwareModule;
|
private SoftwareModule softwareModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,18 +81,11 @@ public class ExternalArtifact extends Artifact {
|
|||||||
return softwareModule;
|
return softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param softwareModule
|
|
||||||
* the softwareModule to set
|
|
||||||
*/
|
|
||||||
public final void setSoftwareModule(final SoftwareModule softwareModule) {
|
public final void setSoftwareModule(final SoftwareModule softwareModule) {
|
||||||
this.softwareModule = softwareModule;
|
this.softwareModule = softwareModule;
|
||||||
this.softwareModule.addArtifact(this);
|
this.softwareModule.addArtifact(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the externalArtifactProvider
|
|
||||||
*/
|
|
||||||
public ExternalArtifactProvider getExternalArtifactProvider() {
|
public ExternalArtifactProvider getExternalArtifactProvider() {
|
||||||
return externalArtifactProvider;
|
return externalArtifactProvider;
|
||||||
}
|
}
|
||||||
@@ -104,17 +94,10 @@ public class ExternalArtifact extends Artifact {
|
|||||||
return new StringBuilder().append(externalArtifactProvider.getBasePath()).append(urlSuffix).toString();
|
return new StringBuilder().append(externalArtifactProvider.getBasePath()).append(urlSuffix).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the urlSuffix
|
|
||||||
*/
|
|
||||||
public String getUrlSuffix() {
|
public String getUrlSuffix() {
|
||||||
return urlSuffix;
|
return urlSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param externalArtifactProvider
|
|
||||||
* the externalArtifactProvider to set
|
|
||||||
*/
|
|
||||||
public void setExternalArtifactProvider(final ExternalArtifactProvider externalArtifactProvider) {
|
public void setExternalArtifactProvider(final ExternalArtifactProvider externalArtifactProvider) {
|
||||||
this.externalArtifactProvider = externalArtifactProvider;
|
this.externalArtifactProvider = externalArtifactProvider;
|
||||||
}
|
}
|
||||||
@@ -127,11 +110,6 @@ public class ExternalArtifact extends Artifact {
|
|||||||
this.urlSuffix = urlSuffix;
|
this.urlSuffix = urlSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() { // NOSONAR - as this is generated
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -140,16 +118,8 @@ public class ExternalArtifact extends Artifact {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,8 @@ import javax.persistence.Table;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* External repositories for artifact storage. The SP server provides URLs for
|
* External repositories for artifact storage. The SP server provides URLs for
|
||||||
* the targets to download rom these external ressources but does not access
|
* the targets to download from these external resources but does not access
|
||||||
* thenm itself.
|
* them itself.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Table(name = "sp_external_provider", indexes = {
|
@Table(name = "sp_external_provider", indexes = {
|
||||||
@@ -60,41 +57,22 @@ public class ExternalArtifactProvider extends NamedEntity {
|
|||||||
basePath = "";
|
basePath = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the basePath
|
|
||||||
*/
|
|
||||||
public String getBasePath() {
|
public String getBasePath() {
|
||||||
return basePath;
|
return basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the defaultSuffix
|
|
||||||
*/
|
|
||||||
public String getDefaultSuffix() {
|
public String getDefaultSuffix() {
|
||||||
return defaultSuffix;
|
return defaultSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param basePath
|
|
||||||
* the basePath to set
|
|
||||||
*/
|
|
||||||
public void setBasePath(final String basePath) {
|
public void setBasePath(final String basePath) {
|
||||||
this.basePath = basePath;
|
this.basePath = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param defaultSuffix
|
|
||||||
* the defaultSuffix to set
|
|
||||||
*/
|
|
||||||
public void setDefaultSuffix(final String defaultSuffix) {
|
public void setDefaultSuffix(final String defaultSuffix) {
|
||||||
this.defaultSuffix = defaultSuffix;
|
this.defaultSuffix = defaultSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() { // NOSONAR - as this is generated
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -103,16 +81,8 @@ public class ExternalArtifactProvider extends NamedEntity {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class LocalArtifact extends Artifact {
|
|||||||
private String filename;
|
private String filename;
|
||||||
|
|
||||||
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST })
|
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST })
|
||||||
@JoinColumn(name = "software_module", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_assigned_sm") )
|
@JoinColumn(name = "software_module", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_assigned_sm"))
|
||||||
private SoftwareModule softwareModule;
|
private SoftwareModule softwareModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,11 +73,6 @@ public class LocalArtifact extends Artifact {
|
|||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() { // NOSONAR - as this is generated
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -86,16 +81,8 @@ public class LocalArtifact extends Artifact {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -106,33 +93,20 @@ public class LocalArtifact extends Artifact {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the softwareModule
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public SoftwareModule getSoftwareModule() {
|
public SoftwareModule getSoftwareModule() {
|
||||||
return softwareModule;
|
return softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param softwareModule
|
|
||||||
* the softwareModule to set
|
|
||||||
*/
|
|
||||||
public final void setSoftwareModule(final SoftwareModule softwareModule) {
|
public final void setSoftwareModule(final SoftwareModule softwareModule) {
|
||||||
this.softwareModule = softwareModule;
|
this.softwareModule = softwareModule;
|
||||||
this.softwareModule.addArtifact(this);
|
this.softwareModule.addArtifact(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the gridFsFileName
|
|
||||||
*/
|
|
||||||
public String getGridFsFileName() {
|
public String getGridFsFileName() {
|
||||||
return gridFsFileName;
|
return gridFsFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the filename
|
|
||||||
*/
|
|
||||||
public String getFilename() {
|
public String getFilename() {
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,8 @@ import javax.persistence.Column;
|
|||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link TenantAwareBaseEntity} extension for all entities that are named in addition to
|
* {@link TenantAwareBaseEntity} extension for all entities that are named in
|
||||||
* their technical ID.
|
* addition to their technical ID.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class NamedEntity extends TenantAwareBaseEntity {
|
public abstract class NamedEntity extends TenantAwareBaseEntity {
|
||||||
@@ -40,7 +34,7 @@ public abstract class NamedEntity extends TenantAwareBaseEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* of the {@link NamedEntity}
|
* of the {@link NamedEntity}
|
||||||
* @param description
|
* @param description
|
||||||
@@ -67,4 +61,23 @@ public abstract class NamedEntity extends TenantAwareBaseEntity {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() { // NOSONAR - as this is generated
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof NamedEntity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ import javax.persistence.MappedSuperclass;
|
|||||||
/**
|
/**
|
||||||
* Extension for {@link NamedEntity} that are versioned.
|
* Extension for {@link NamedEntity} that are versioned.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class NamedVersionedEntity extends NamedEntity {
|
public abstract class NamedVersionedEntity extends NamedEntity {
|
||||||
@@ -29,7 +24,7 @@ public abstract class NamedVersionedEntity extends NamedEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* parameterized constructor.
|
* parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* of the entity
|
* of the entity
|
||||||
* @param version
|
* @param version
|
||||||
@@ -53,4 +48,24 @@ public abstract class NamedVersionedEntity extends NamedEntity {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof NamedVersionedEntity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,20 +36,20 @@ import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_rollout", indexes = {
|
@Table(name = "sp_rollout", indexes = {
|
||||||
@Index(name = "sp_idx_rollout_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_rollout_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
"name", "tenant" }, name = "uk_rollout") )
|
"name", "tenant" }, name = "uk_rollout"))
|
||||||
public class Rollout extends NamedEntity {
|
public class Rollout extends NamedEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@OneToMany(targetEntity = RolloutGroup.class)
|
@OneToMany(targetEntity = RolloutGroup.class)
|
||||||
@JoinColumn(name = "rollout", insertable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_rolloutgroup") )
|
@JoinColumn(name = "rollout", insertable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_rolloutgroup"))
|
||||||
private List<RolloutGroup> rolloutGroups;
|
private List<RolloutGroup> rolloutGroups;
|
||||||
|
|
||||||
@Column(name = "target_filter", length = 1024, nullable = false)
|
@Column(name = "target_filter", length = 1024, nullable = false)
|
||||||
private String targetFilterQuery;
|
private String targetFilterQuery;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds") )
|
@JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds"))
|
||||||
private DistributionSet distributionSet;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
@@ -79,159 +79,86 @@ public class Rollout extends NamedEntity {
|
|||||||
@Transient
|
@Transient
|
||||||
private transient TotalTargetCountStatus totalTargetCountStatus;
|
private transient TotalTargetCountStatus totalTargetCountStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the distributionSet
|
|
||||||
*/
|
|
||||||
public DistributionSet getDistributionSet() {
|
public DistributionSet getDistributionSet() {
|
||||||
return distributionSet;
|
return distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param distributionSet
|
|
||||||
* the distributionSet to set
|
|
||||||
*/
|
|
||||||
public void setDistributionSet(final DistributionSet distributionSet) {
|
public void setDistributionSet(final DistributionSet distributionSet) {
|
||||||
this.distributionSet = distributionSet;
|
this.distributionSet = distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rolloutGroups
|
|
||||||
*/
|
|
||||||
public List<RolloutGroup> getRolloutGroups() {
|
public List<RolloutGroup> getRolloutGroups() {
|
||||||
return rolloutGroups;
|
return rolloutGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rolloutGroups
|
|
||||||
* the rolloutGroups to set
|
|
||||||
*/
|
|
||||||
public void setRolloutGroups(final List<RolloutGroup> rolloutGroups) {
|
public void setRolloutGroups(final List<RolloutGroup> rolloutGroups) {
|
||||||
this.rolloutGroups = rolloutGroups;
|
this.rolloutGroups = rolloutGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the targetFilterQuery
|
|
||||||
*/
|
|
||||||
public String getTargetFilterQuery() {
|
public String getTargetFilterQuery() {
|
||||||
return targetFilterQuery;
|
return targetFilterQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param targetFilterQuery
|
|
||||||
* the targetFilterQuery to set
|
|
||||||
*/
|
|
||||||
public void setTargetFilterQuery(final String targetFilterQuery) {
|
public void setTargetFilterQuery(final String targetFilterQuery) {
|
||||||
this.targetFilterQuery = targetFilterQuery;
|
this.targetFilterQuery = targetFilterQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the status
|
|
||||||
*/
|
|
||||||
public RolloutStatus getStatus() {
|
public RolloutStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param status
|
|
||||||
* the status to set
|
|
||||||
*/
|
|
||||||
public void setStatus(final RolloutStatus status) {
|
public void setStatus(final RolloutStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the lastCheck
|
|
||||||
*/
|
|
||||||
public long getLastCheck() {
|
public long getLastCheck() {
|
||||||
return lastCheck;
|
return lastCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lastCheck
|
|
||||||
* the lastCheck to set
|
|
||||||
*/
|
|
||||||
public void setLastCheck(final long lastCheck) {
|
public void setLastCheck(final long lastCheck) {
|
||||||
this.lastCheck = lastCheck;
|
this.lastCheck = lastCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionType
|
|
||||||
*/
|
|
||||||
public ActionType getActionType() {
|
public ActionType getActionType() {
|
||||||
return actionType;
|
return actionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param actionType
|
|
||||||
* the actionType to set
|
|
||||||
*/
|
|
||||||
public void setActionType(final ActionType actionType) {
|
public void setActionType(final ActionType actionType) {
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the forcedTime
|
|
||||||
*/
|
|
||||||
public long getForcedTime() {
|
public long getForcedTime() {
|
||||||
return forcedTime;
|
return forcedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param forcedTime
|
|
||||||
* the forcedTime to set
|
|
||||||
*/
|
|
||||||
public void setForcedTime(final long forcedTime) {
|
public void setForcedTime(final long forcedTime) {
|
||||||
this.forcedTime = forcedTime;
|
this.forcedTime = forcedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the totalTargets
|
|
||||||
*/
|
|
||||||
public long getTotalTargets() {
|
public long getTotalTargets() {
|
||||||
return totalTargets;
|
return totalTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param totalTargets
|
|
||||||
* the totalTargets to set
|
|
||||||
*/
|
|
||||||
public void setTotalTargets(final long totalTargets) {
|
public void setTotalTargets(final long totalTargets) {
|
||||||
this.totalTargets = totalTargets;
|
this.totalTargets = totalTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rolloutGroupsTotal
|
|
||||||
*/
|
|
||||||
public int getRolloutGroupsTotal() {
|
public int getRolloutGroupsTotal() {
|
||||||
return rolloutGroupsTotal;
|
return rolloutGroupsTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rolloutGroupsTotal
|
|
||||||
* the rolloutGroupsTotal to set
|
|
||||||
*/
|
|
||||||
public void setRolloutGroupsTotal(final int rolloutGroupsTotal) {
|
public void setRolloutGroupsTotal(final int rolloutGroupsTotal) {
|
||||||
this.rolloutGroupsTotal = rolloutGroupsTotal;
|
this.rolloutGroupsTotal = rolloutGroupsTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rolloutGroupsCreated
|
|
||||||
*/
|
|
||||||
public int getRolloutGroupsCreated() {
|
public int getRolloutGroupsCreated() {
|
||||||
return rolloutGroupsCreated;
|
return rolloutGroupsCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rolloutGroupsCreated
|
|
||||||
* the rolloutGroupsCreated to set
|
|
||||||
*/
|
|
||||||
public void setRolloutGroupsCreated(final int rolloutGroupsCreated) {
|
public void setRolloutGroupsCreated(final int rolloutGroupsCreated) {
|
||||||
this.rolloutGroupsCreated = rolloutGroupsCreated;
|
this.rolloutGroupsCreated = rolloutGroupsCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the totalTargetCountStatus
|
|
||||||
*/
|
|
||||||
public TotalTargetCountStatus getTotalTargetCountStatus() {
|
public TotalTargetCountStatus getTotalTargetCountStatus() {
|
||||||
if (totalTargetCountStatus == null) {
|
if (totalTargetCountStatus == null) {
|
||||||
totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
|
totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
|
||||||
@@ -239,10 +166,6 @@ public class Rollout extends NamedEntity {
|
|||||||
return totalTargetCountStatus;
|
return totalTargetCountStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param totalTargetCountStatus
|
|
||||||
* the totalTargetCountStatus to set
|
|
||||||
*/
|
|
||||||
public void setTotalTargetCountStatus(final TotalTargetCountStatus totalTargetCountStatus) {
|
public void setTotalTargetCountStatus(final TotalTargetCountStatus totalTargetCountStatus) {
|
||||||
this.totalTargetCountStatus = totalTargetCountStatus;
|
this.totalTargetCountStatus = totalTargetCountStatus;
|
||||||
}
|
}
|
||||||
@@ -256,7 +179,7 @@ public class Rollout extends NamedEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Michael Hirsch
|
* State machine for rollout.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum RolloutStatus {
|
public enum RolloutStatus {
|
||||||
@@ -308,4 +231,24 @@ public class Rollout extends NamedEntity {
|
|||||||
*/
|
*/
|
||||||
ERROR_STARTING;
|
ERROR_STARTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof Rollout)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ import javax.persistence.UniqueConstraint;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_rolloutgroup", indexes = {
|
@Table(name = "sp_rolloutgroup", indexes = {
|
||||||
@Index(name = "sp_idx_rolloutgroup_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_rolloutgroup_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
"name", "rollout", "tenant" }, name = "uk_rolloutgroup") )
|
"name", "rollout", "tenant" }, name = "uk_rolloutgroup"))
|
||||||
public class RolloutGroup extends NamedEntity {
|
public class RolloutGroup extends NamedEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "rollout", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolloutgroup_rollout") )
|
@JoinColumn(name = "rollout", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolloutgroup_rollout"))
|
||||||
private Rollout rollout;
|
private Rollout rollout;
|
||||||
|
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
@@ -210,8 +210,7 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Rollout goup state machine.
|
||||||
* @author Michael Hirsch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum RolloutGroupStatus {
|
public enum RolloutGroupStatus {
|
||||||
@@ -478,4 +477,24 @@ public class RolloutGroup extends NamedEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof RolloutGroup)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,9 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Combined unique key of the table {@link RolloutTargetGroup}.
|
* Combined unique key of the table {@link RolloutTargetGroup}.
|
||||||
*
|
|
||||||
* @author Michael Hirsch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RolloutTargetGroupId implements Serializable {
|
public class RolloutTargetGroupId implements Serializable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Long rolloutGroup;
|
private Long rolloutGroup;
|
||||||
|
|||||||
@@ -33,17 +33,12 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Software Module that is supported by OS level provisioning mechanism on
|
* Base Software Module that is supported by OS level provisioning mechanism on
|
||||||
* the edge controller, e.g. OS, JVM, AgentHub
|
* the edge controller, e.g. OS, JVM, AgentHub.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_base_software_module", uniqueConstraints = @UniqueConstraint(columnNames = { "module_type", "name",
|
@Table(name = "sp_base_software_module", uniqueConstraints = @UniqueConstraint(columnNames = { "module_type", "name",
|
||||||
"version", "tenant" }, name = "uk_base_sw_mod") , indexes = {
|
"version", "tenant" }, name = "uk_base_sw_mod"), indexes = {
|
||||||
@Index(name = "sp_idx_base_sw_module_01", columnList = "tenant,deleted,name,version"),
|
@Index(name = "sp_idx_base_sw_module_01", columnList = "tenant,deleted,name,version"),
|
||||||
@Index(name = "sp_idx_base_sw_module_02", columnList = "tenant,deleted,module_type"),
|
@Index(name = "sp_idx_base_sw_module_02", columnList = "tenant,deleted,module_type"),
|
||||||
@Index(name = "sp_idx_base_sw_module_prim", columnList = "tenant,id") })
|
@Index(name = "sp_idx_base_sw_module_prim", columnList = "tenant,id") })
|
||||||
@@ -52,7 +47,7 @@ public class SoftwareModule extends NamedVersionedEntity {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "module_type", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_module_type") )
|
@JoinColumn(name = "module_type", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_module_type"))
|
||||||
private SoftwareModuleType type;
|
private SoftwareModuleType type;
|
||||||
|
|
||||||
@ManyToMany(mappedBy = "modules", targetEntity = DistributionSet.class, fetch = FetchType.LAZY)
|
@ManyToMany(mappedBy = "modules", targetEntity = DistributionSet.class, fetch = FetchType.LAZY)
|
||||||
@@ -213,17 +208,10 @@ public class SoftwareModule extends NamedVersionedEntity {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the deleted
|
|
||||||
*/
|
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param deleted
|
|
||||||
* the deleted to set
|
|
||||||
*/
|
|
||||||
public void setDeleted(final boolean deleted) {
|
public void setDeleted(final boolean deleted) {
|
||||||
this.deleted = deleted;
|
this.deleted = deleted;
|
||||||
}
|
}
|
||||||
@@ -233,29 +221,18 @@ public class SoftwareModule extends NamedVersionedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the metadata
|
* @return immutable list of meta data elements.
|
||||||
*/
|
*/
|
||||||
public List<SoftwareModuleMetadata> getMetadata() {
|
public List<SoftwareModuleMetadata> getMetadata() {
|
||||||
return metadata;
|
return Collections.unmodifiableList(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SoftwareModule [type=" + type + ", deleted=" + deleted + ", getVersion()=" + getVersion()
|
return "SoftwareModule [deleted=" + deleted + ", name=" + getName() + ", version=" + getVersion()
|
||||||
+ ", getOptLockRevision()=" + getOptLockRevision() + ", getId()=" + getId() + ", getType()="
|
+ ", revision=" + getOptLockRevision() + ", Id=" + getId() + ", type=" + getType().getName() + "]";
|
||||||
+ getType().getName() + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() { // NOSONAR - as this is generated
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -264,16 +241,8 @@ public class SoftwareModule extends NamedVersionedEntity {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* To hold software module name and Id.
|
* To hold software module name and Id.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SoftwareModuleIdName implements Serializable {
|
public class SoftwareModuleIdName implements Serializable {
|
||||||
|
|
||||||
@@ -35,25 +33,14 @@ public class SoftwareModuleIdName implements Serializable {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {// NOSONAR - as this is generated
|
public int hashCode() {// NOSONAR - as this is generated
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -62,11 +49,6 @@ public class SoftwareModuleIdName implements Serializable {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
|
|||||||
@@ -24,18 +24,11 @@ import javax.persistence.Table;
|
|||||||
/**
|
/**
|
||||||
* Metadata for {@link SoftwareModule}.
|
* Metadata for {@link SoftwareModule}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@IdClass(SwMetadataCompositeKey.class)
|
@IdClass(SwMetadataCompositeKey.class)
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_sw_metadata")
|
@Table(name = "sp_sw_metadata")
|
||||||
public class SoftwareModuleMetadata implements Serializable {
|
public class SoftwareModuleMetadata implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -50,18 +43,21 @@ public class SoftwareModuleMetadata implements Serializable {
|
|||||||
@JoinColumn(name = "sw_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
@JoinColumn(name = "sw_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
||||||
private SoftwareModule softwareModule;
|
private SoftwareModule softwareModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor for JPA.
|
||||||
|
*/
|
||||||
public SoftwareModuleMetadata() {
|
public SoftwareModuleMetadata() {
|
||||||
|
// default constructor for JPA.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Standard constructor.
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* of the metadata element
|
* of the meta data element
|
||||||
* @param softwareModule
|
* @param softwareModule
|
||||||
* @param value
|
* @param value
|
||||||
* of the metadata element
|
* of the meta data element
|
||||||
*/
|
*/
|
||||||
public SoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
|
public SoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
@@ -69,56 +65,75 @@ public class SoftwareModuleMetadata implements Serializable {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
public SwMetadataCompositeKey getId() {
|
public SwMetadataCompositeKey getId() {
|
||||||
return new SwMetadataCompositeKey(softwareModule, key);
|
return new SwMetadataCompositeKey(softwareModule, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the value
|
|
||||||
*/
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param value
|
|
||||||
* the value to set
|
|
||||||
*/
|
|
||||||
public void setValue(final String value) {
|
public void setValue(final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the softwareModule
|
|
||||||
*/
|
|
||||||
public SoftwareModule getSoftwareModule() {
|
public SoftwareModule getSoftwareModule() {
|
||||||
return softwareModule;
|
return softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param softwareModule
|
|
||||||
* the softwareModule to set
|
|
||||||
*/
|
|
||||||
public void setSoftwareModule(final SoftwareModule softwareModule) {
|
public void setSoftwareModule(final SoftwareModule softwareModule) {
|
||||||
this.softwareModule = softwareModule;
|
this.softwareModule = softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the key
|
|
||||||
*/
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param key
|
|
||||||
* the key to set
|
|
||||||
*/
|
|
||||||
public void setKey(final String key) {
|
public void setKey(final String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SoftwareModuleMetadata [key=" + key + ", value=" + value + ", softwareModule=" + softwareModule + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
||||||
|
result = prime * result + ((softwareModule == null) ? 0 : softwareModule.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof SoftwareModuleMetadata)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final SoftwareModuleMetadata other = (SoftwareModuleMetadata) obj;
|
||||||
|
if (key == null) {
|
||||||
|
if (other.key != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!key.equals(other.key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (softwareModule == null) {
|
||||||
|
if (other.softwareModule != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!softwareModule.equals(other.softwareModule)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ import javax.persistence.UniqueConstraint;
|
|||||||
/**
|
/**
|
||||||
* Type of a software modules.
|
* Type of a software modules.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_software_module_type", indexes = {
|
@Table(name = "sp_software_module_type", indexes = {
|
||||||
@@ -28,9 +25,6 @@ import javax.persistence.UniqueConstraint;
|
|||||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_smt_type_key"),
|
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_smt_type_key"),
|
||||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_smt_name") })
|
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_smt_name") })
|
||||||
public class SoftwareModuleType extends NamedEntity {
|
public class SoftwareModuleType extends NamedEntity {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "type_key", nullable = false, length = 64)
|
@Column(name = "type_key", nullable = false, length = 64)
|
||||||
@@ -92,48 +86,26 @@ public class SoftwareModuleType extends NamedEntity {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the key
|
|
||||||
*/
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the max
|
|
||||||
*/
|
|
||||||
public int getMaxAssignments() {
|
public int getMaxAssignments() {
|
||||||
return maxAssignments;
|
return maxAssignments;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the deleted
|
|
||||||
*/
|
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param deleted
|
|
||||||
* the deleted to set
|
|
||||||
*/
|
|
||||||
public void setDeleted(final boolean deleted) {
|
public void setDeleted(final boolean deleted) {
|
||||||
this.deleted = deleted;
|
this.deleted = deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the software type color
|
|
||||||
*/
|
|
||||||
public String getColour() {
|
public String getColour() {
|
||||||
return colour;
|
return colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param colour
|
|
||||||
* the col
|
|
||||||
*/
|
|
||||||
public void setColour(final String colour) {
|
public void setColour(final String colour) {
|
||||||
this.colour = colour;
|
this.colour = colour;
|
||||||
}
|
}
|
||||||
@@ -143,4 +115,23 @@ public class SoftwareModuleType extends NamedEntity {
|
|||||||
return "SoftwareModuleType [key=" + key + ", getName()=" + getName() + ", getId()=" + getId() + "]";
|
return "SoftwareModuleType [key=" + key + ", getName()=" + getName() + ", getId()=" + getId() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof SoftwareModuleType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,10 @@ package org.eclipse.hawkbit.repository.model;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Software Module Metadata composite key which contains the meta data key
|
* The Software Module meta data composite key which contains the meta data key
|
||||||
* and the ID of the software module itself.
|
* and the ID of the software module itself.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class SwMetadataCompositeKey implements Serializable {
|
public final class SwMetadataCompositeKey implements Serializable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
@@ -28,9 +22,10 @@ public final class SwMetadataCompositeKey implements Serializable {
|
|||||||
private Long softwareModule;
|
private Long softwareModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default constructor for JPA.
|
||||||
*/
|
*/
|
||||||
public SwMetadataCompositeKey() {
|
public SwMetadataCompositeKey() {
|
||||||
|
// Default constructor for JPA.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,25 +69,15 @@ public final class SwMetadataCompositeKey implements Serializable {
|
|||||||
this.softwareModule = softwareModule;
|
this.softwareModule = softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
result = prime * result + (key == null ? 0 : key.hashCode());
|
||||||
result = prime * result + ((softwareModule == null) ? 0 : softwareModule.hashCode());
|
result = prime * result + (softwareModule == null ? 0 : softwareModule.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
// code
|
// code
|
||||||
|
|||||||
@@ -14,14 +14,9 @@ import javax.persistence.MappedSuperclass;
|
|||||||
import org.springframework.hateoas.Identifiable;
|
import org.springframework.hateoas.Identifiable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Tag can be used as describing and organisational meta information for any
|
* A Tag can be used as describing and organizational meta information for any
|
||||||
* kind of entity.
|
* kind of entity.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class Tag extends NamedEntity implements Identifiable<Long> {
|
public abstract class Tag extends NamedEntity implements Identifiable<Long> {
|
||||||
@@ -57,14 +52,28 @@ public abstract class Tag extends NamedEntity implements Identifiable<Long> {
|
|||||||
this.colour = colour;
|
this.colour = colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Tag [getOptLockRevision()=" + getOptLockRevision() + ", getId()=" + getId() + "]";
|
return "Tag [getOptLockRevision()=" + getOptLockRevision() + ", getId()=" + getId() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof Tag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,6 @@ import org.springframework.data.domain.Persistable;
|
|||||||
* {@link TargetStatus#REGISTERED}, i.e. a target {@link DistributionSet} .
|
* {@link TargetStatus#REGISTERED}, i.e. a target {@link DistributionSet} .
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_target", indexes = {
|
@Table(name = "sp_target", indexes = {
|
||||||
@@ -117,7 +112,7 @@ public class Target extends NamedEntity implements Persistable<Long> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param controllerId
|
* @param controllerId
|
||||||
* controller ID of the {@link Target}
|
* controller ID of the {@link Target}
|
||||||
*/
|
*/
|
||||||
@@ -136,15 +131,18 @@ public class Target extends NamedEntity implements Persistable<Long> {
|
|||||||
securityToken = null;
|
securityToken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: For Target we extended the general strategy by adding controllerId
|
||||||
|
* as well.
|
||||||
|
*
|
||||||
|
* @see org.eclipse.hawkbit.repository.model.BaseEntity#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof Target)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Target other = (Target) obj;
|
final Target other = (Target) obj;
|
||||||
@@ -182,25 +180,14 @@ public class Target extends NamedEntity implements Persistable<Long> {
|
|||||||
this.assignedDistributionSet = assignedDistributionSet;
|
this.assignedDistributionSet = assignedDistributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param controllerId
|
|
||||||
* the controllerId to set
|
|
||||||
*/
|
|
||||||
public void setControllerId(final String controllerId) {
|
public void setControllerId(final String controllerId) {
|
||||||
this.controllerId = controllerId;
|
this.controllerId = controllerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tags
|
|
||||||
* the tags to set
|
|
||||||
*/
|
|
||||||
public void setTags(final Set<TargetTag> tags) {
|
public void setTags(final Set<TargetTag> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actions
|
|
||||||
*/
|
|
||||||
public List<Action> getActions() {
|
public List<Action> getActions() {
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
@@ -209,11 +196,6 @@ public class Target extends NamedEntity implements Persistable<Long> {
|
|||||||
return new TargetIdName(getId(), getControllerId(), getName());
|
return new TargetIdName(getId(), getControllerId(), getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.data.domain.Persistable#isNew()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@Transient
|
@Transient
|
||||||
public boolean isNew() {
|
public boolean isNew() {
|
||||||
@@ -261,11 +243,6 @@ public class Target extends NamedEntity implements Persistable<Long> {
|
|||||||
this.securityToken = securityToken;
|
this.securityToken = securityToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Target [controllerId=" + controllerId + ", getId()=" + getId() + "]";
|
return "Target [controllerId=" + controllerId + ", getId()=" + getId() + "]";
|
||||||
|
|||||||
@@ -15,18 +15,14 @@ import javax.persistence.Table;
|
|||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stored target filter.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_target_filter_query", indexes = {
|
@Table(name = "sp_target_filter_query", indexes = {
|
||||||
@Index(name = "sp_idx_target_filter_query_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_target_filter_query_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
"name", "tenant" }, name = "uk_tenant_custom_filter_name") )
|
"name", "tenant" }, name = "uk_tenant_custom_filter_name"))
|
||||||
public class TargetFilterQuery extends TenantAwareBaseEntity {
|
public class TargetFilterQuery extends TenantAwareBaseEntity {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 7493966984413479089L;
|
private static final long serialVersionUID = 7493966984413479089L;
|
||||||
|
|
||||||
@Column(name = "name", length = 64)
|
@Column(name = "name", length = 64)
|
||||||
@@ -36,8 +32,7 @@ public class TargetFilterQuery extends TenantAwareBaseEntity {
|
|||||||
private String query;
|
private String query;
|
||||||
|
|
||||||
public TargetFilterQuery() {
|
public TargetFilterQuery() {
|
||||||
name = null;
|
// Default constructor for JPA.
|
||||||
query = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetFilterQuery(final String name, final String query) {
|
public TargetFilterQuery(final String name, final String query) {
|
||||||
@@ -45,63 +40,39 @@ public class TargetFilterQuery extends TenantAwareBaseEntity {
|
|||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* the name to set
|
|
||||||
*/
|
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the query
|
|
||||||
*/
|
|
||||||
public String getQuery() {
|
public String getQuery() {
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param query
|
|
||||||
* the query to set
|
|
||||||
*/
|
|
||||||
public void setQuery(final String query) {
|
public void setQuery(final String query) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
public int hashCode() {
|
||||||
if (this == obj) {
|
final int prime = 31;
|
||||||
return true;
|
int result = super.hashCode();
|
||||||
}
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
if (obj == null) {
|
return result;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final TargetFilterQuery other = (TargetFilterQuery) obj;
|
|
||||||
if (name == null) {
|
|
||||||
if (other.name != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!name.equals(other.name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) {
|
||||||
final int prime = 31;
|
if (!super.equals(obj)) {
|
||||||
int result = 1;
|
return false;
|
||||||
result = prime * result + (name == null ? 0 : name.hashCode());
|
}
|
||||||
return result;
|
if (!(obj instanceof TargetFilterQuery)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,12 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* ID class of the {@link Target} which contains the
|
* ID class of the {@link Target} which contains the
|
||||||
* {@link Target#getControllerId()} and the {@link Target#getName()} in one
|
* {@link Target#getControllerId()} and the {@link Target#getName()} in one
|
||||||
* object. Often it's necessary to remeber the IDs of the {@link Target} and the
|
* object. Often it's necessary to remember the IDs of the {@link Target} and
|
||||||
* resolve for e.g. the UI the name of the target, this is very costly
|
* the resolve for e.g. the UI the name of the target, this is very costly
|
||||||
* operation, so it's much better if the ID and the name of the {@link Target}
|
* operation, so it's much better if the ID and the name of the {@link Target}
|
||||||
* is already in memory available.
|
* is already in memory available.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TargetIdName implements Serializable {
|
public class TargetIdName implements Serializable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final long targetId;
|
private final long targetId;
|
||||||
@@ -46,61 +39,34 @@ public class TargetIdName implements Serializable {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the controller id
|
|
||||||
*/
|
|
||||||
public String getControllerId() {
|
public String getControllerId() {
|
||||||
return controllerId;
|
return controllerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id
|
|
||||||
* the id to set
|
|
||||||
*/
|
|
||||||
public void setControllerId(final String id) {
|
public void setControllerId(final String id) {
|
||||||
this.controllerId = id;
|
controllerId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* the name to set
|
|
||||||
*/
|
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the targetId
|
|
||||||
*/
|
|
||||||
public long getTargetId() {
|
public long getTargetId() {
|
||||||
return targetId;
|
return targetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + (int) (targetId ^ (targetId >>> 32));
|
result = prime * result + (int) (targetId ^ targetId >>> 32);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
@@ -119,11 +85,6 @@ public class TargetIdName implements Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// only return the ID because it's used in vaadin for setting the item
|
// only return the ID because it's used in vaadin for setting the item
|
||||||
|
|||||||
@@ -54,19 +54,11 @@ import org.springframework.data.domain.Persistable;
|
|||||||
* modifying the {@link Target} itself when a controller reports it's
|
* modifying the {@link Target} itself when a controller reports it's
|
||||||
* {@link #lastTargetQuery} for example.
|
* {@link #lastTargetQuery} for example.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Table(name = "sp_target_info", indexes = {
|
@Table(name = "sp_target_info", indexes = {
|
||||||
@Index(name = "sp_idx_target_info_02", columnList = "target_id,update_status") })
|
@Index(name = "sp_idx_target_info_02", columnList = "target_id,update_status") })
|
||||||
@Entity
|
@Entity
|
||||||
// @DynamicUpdate
|
|
||||||
public class TargetInfo implements Persistable<Long>, Serializable {
|
public class TargetInfo implements Persistable<Long>, Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TargetInfo.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TargetInfo.class);
|
||||||
@@ -81,9 +73,6 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
@OneToOne(cascade = { CascadeType.MERGE, CascadeType.REMOVE }, fetch = FetchType.LAZY, targetEntity = Target.class)
|
@OneToOne(cascade = { CascadeType.MERGE, CascadeType.REMOVE }, fetch = FetchType.LAZY, targetEntity = Target.class)
|
||||||
@JoinColumn(name = "target_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_stat_targ"))
|
@JoinColumn(name = "target_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_stat_targ"))
|
||||||
@MapsId
|
@MapsId
|
||||||
// use deprecated annotation until HHH-8862 is fixed
|
|
||||||
// @SuppressWarnings( "deprecation" )
|
|
||||||
// @org.hibernate.annotations.ForeignKey( name = "fk_targ_stat_targ" )
|
|
||||||
private Target target;
|
private Target target;
|
||||||
|
|
||||||
@Column(name = "address", length = 512)
|
@Column(name = "address", length = 512)
|
||||||
@@ -111,9 +100,7 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
@MapKeyColumn(name = "attribute_key", nullable = false, length = 32)
|
@MapKeyColumn(name = "attribute_key", nullable = false, length = 32)
|
||||||
@CollectionTable(name = "sp_target_attributes", joinColumns = {
|
@CollectionTable(name = "sp_target_attributes", joinColumns = {
|
||||||
@JoinColumn(name = "target_id") }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
@JoinColumn(name = "target_id") }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
||||||
// use deprecated annotation until HHH-8862 is fixed
|
|
||||||
|
|
||||||
// @org.hibernate.annotations.ForeignKey( name = "fk_targ_attrib_target" )
|
|
||||||
private final Map<String, String> controllerAttributes = Collections.synchronizedMap(new HashMap<String, String>());
|
private final Map<String, String> controllerAttributes = Collections.synchronizedMap(new HashMap<String, String>());
|
||||||
|
|
||||||
// set default request controller attributes to true, because we want to
|
// set default request controller attributes to true, because we want to
|
||||||
@@ -124,7 +111,7 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for {@link TargetStatus}.
|
* Constructor for {@link TargetStatus}.
|
||||||
*
|
*
|
||||||
* @param target
|
* @param target
|
||||||
* related to this status.
|
* related to this status.
|
||||||
*/
|
*/
|
||||||
@@ -138,21 +125,11 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
targetId = null;
|
targetId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.data.domain.Persistable#getId()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return targetId;
|
return targetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.data.domain.Persistable#isNew()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@Transient
|
@Transient
|
||||||
public boolean isNew() {
|
public boolean isNew() {
|
||||||
@@ -198,114 +175,62 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the targetId
|
|
||||||
*/
|
|
||||||
public Long getTargetId() {
|
public Long getTargetId() {
|
||||||
return targetId;
|
return targetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param targetId
|
|
||||||
* the targetId to set
|
|
||||||
*/
|
|
||||||
public void setTargetId(final Long targetId) {
|
public void setTargetId(final Long targetId) {
|
||||||
this.targetId = targetId;
|
this.targetId = targetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the target
|
|
||||||
*/
|
|
||||||
public Target getTarget() {
|
public Target getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param target
|
|
||||||
* the target to set
|
|
||||||
*/
|
|
||||||
public void setTarget(final Target target) {
|
public void setTarget(final Target target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the lastTargetQuery
|
|
||||||
*/
|
|
||||||
public Long getLastTargetQuery() {
|
public Long getLastTargetQuery() {
|
||||||
return lastTargetQuery;
|
return lastTargetQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lastTargetQuery
|
|
||||||
* the lastTargetQuery to set
|
|
||||||
*/
|
|
||||||
public void setLastTargetQuery(final Long lastTargetQuery) {
|
public void setLastTargetQuery(final Long lastTargetQuery) {
|
||||||
this.lastTargetQuery = lastTargetQuery;
|
this.lastTargetQuery = lastTargetQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param requestControllerAttributes
|
|
||||||
* the requestControllerAttributes to set
|
|
||||||
*/
|
|
||||||
public void setRequestControllerAttributes(final boolean requestControllerAttributes) {
|
public void setRequestControllerAttributes(final boolean requestControllerAttributes) {
|
||||||
this.requestControllerAttributes = requestControllerAttributes;
|
this.requestControllerAttributes = requestControllerAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the controllerAttributes
|
|
||||||
*/
|
|
||||||
public Map<String, String> getControllerAttributes() {
|
public Map<String, String> getControllerAttributes() {
|
||||||
return controllerAttributes;
|
return controllerAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the requestControllerAttributes
|
|
||||||
*/
|
|
||||||
public boolean isRequestControllerAttributes() {
|
public boolean isRequestControllerAttributes() {
|
||||||
return requestControllerAttributes;
|
return requestControllerAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the installationDate
|
|
||||||
*/
|
|
||||||
public Long getInstallationDate() {
|
public Long getInstallationDate() {
|
||||||
return installationDate;
|
return installationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param installationDate
|
|
||||||
* the installationDate to set
|
|
||||||
*/
|
|
||||||
public void setInstallationDate(final Long installationDate) {
|
public void setInstallationDate(final Long installationDate) {
|
||||||
this.installationDate = installationDate;
|
this.installationDate = installationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the updateStatus
|
|
||||||
*/
|
|
||||||
public TargetUpdateStatus getUpdateStatus() {
|
public TargetUpdateStatus getUpdateStatus() {
|
||||||
return updateStatus;
|
return updateStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param updateStatus
|
|
||||||
* the updateStatus to set
|
|
||||||
*/
|
|
||||||
public void setUpdateStatus(final TargetUpdateStatus updateStatus) {
|
public void setUpdateStatus(final TargetUpdateStatus updateStatus) {
|
||||||
this.updateStatus = updateStatus;
|
this.updateStatus = updateStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the installedDistributionSet
|
|
||||||
*/
|
|
||||||
public DistributionSet getInstalledDistributionSet() {
|
public DistributionSet getInstalledDistributionSet() {
|
||||||
return installedDistributionSet;
|
return installedDistributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param installedDistributionSet
|
|
||||||
* the installedDistributionSet to set
|
|
||||||
*/
|
|
||||||
public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) {
|
public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) {
|
||||||
this.installedDistributionSet = installedDistributionSet;
|
this.installedDistributionSet = installedDistributionSet;
|
||||||
}
|
}
|
||||||
@@ -338,8 +263,6 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
* The poll time object which holds all the necessary information around the
|
* The poll time object which holds all the necessary information around the
|
||||||
* target poll time, e.g. the last poll time, the next poll time and the
|
* target poll time, e.g. the last poll time, the next poll time and the
|
||||||
* overdue poll time.
|
* overdue poll time.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static final class PollStatus {
|
public static final class PollStatus {
|
||||||
@@ -359,7 +282,7 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
/**
|
/**
|
||||||
* calculates if the target poll time is overdue and the target has not
|
* calculates if the target poll time is overdue and the target has not
|
||||||
* been polled in the configured poll time interval.
|
* been polled in the configured poll time interval.
|
||||||
*
|
*
|
||||||
* @return {@code true} if the current time is after the poll time
|
* @return {@code true} if the current time is after the poll time
|
||||||
* overdue date otherwise {@code false}.
|
* overdue date otherwise {@code false}.
|
||||||
*/
|
*/
|
||||||
@@ -386,15 +309,48 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
return currentDate;
|
return currentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PollTime [lastPollDate=" + lastPollDate + ", nextPollDate=" + nextPollDate + ", overdueDate="
|
return "PollTime [lastPollDate=" + lastPollDate + ", nextPollDate=" + nextPollDate + ", overdueDate="
|
||||||
+ overdueDate + ", currentDate=" + currentDate + "]";
|
+ overdueDate + ", currentDate=" + currentDate + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((target == null) ? 0 : target.hashCode());
|
||||||
|
result = prime * result + ((targetId == null) ? 0 : targetId.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof TargetInfo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final TargetInfo other = (TargetInfo) obj;
|
||||||
|
if (target == null) {
|
||||||
|
if (other.target != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!target.equals(other.target)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (targetId == null) {
|
||||||
|
if (other.targetId != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!targetId.equals(other.targetId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,11 @@ import javax.persistence.UniqueConstraint;
|
|||||||
* A {@link TargetTag} is used to describe Target attributes and use them also
|
* A {@link TargetTag} is used to describe Target attributes and use them also
|
||||||
* for filtering the target list.
|
* for filtering the target list.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_target_tag", indexes = {
|
@Table(name = "sp_target_tag", indexes = {
|
||||||
@Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
"name", "tenant" }, name = "uk_targ_tag") )
|
"name", "tenant" }, name = "uk_targ_tag"))
|
||||||
public class TargetTag extends Tag {
|
public class TargetTag extends Tag {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -65,18 +60,10 @@ public class TargetTag extends Tag {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assignedToTargets
|
|
||||||
*/
|
|
||||||
public List<Target> getAssignedToTargets() {
|
public List<Target> getAssignedToTargets() {
|
||||||
return assignedToTargets;
|
return assignedToTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -85,16 +72,8 @@ public class TargetTag extends Tag {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,10 @@ package org.eclipse.hawkbit.repository.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result object for {@link TargetTag} assigments.
|
* Result object for {@link TargetTag} assignments.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TargetTagAssigmentResult extends AssignmentResult {
|
public class TargetTagAssignmentResult extends AssignmentResult {
|
||||||
|
|
||||||
private final int unassigned;
|
private final int unassigned;
|
||||||
private final List<Target> assignedTargets;
|
private final List<Target> assignedTargets;
|
||||||
@@ -40,7 +37,7 @@ public class TargetTagAssigmentResult extends AssignmentResult {
|
|||||||
* @param targetTag
|
* @param targetTag
|
||||||
* the assigned or unassigned tag
|
* the assigned or unassigned tag
|
||||||
*/
|
*/
|
||||||
public TargetTagAssigmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
public TargetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
||||||
final List<Target> assignedTargets, final List<Target> unassignedTargets, final TargetTag targetTag) {
|
final List<Target> assignedTargets, final List<Target> unassignedTargets, final TargetTag targetTag) {
|
||||||
super(assigned, alreadyAssigned);
|
super(assigned, alreadyAssigned);
|
||||||
this.unassigned = unassigned;
|
this.unassigned = unassigned;
|
||||||
@@ -49,23 +46,14 @@ public class TargetTagAssigmentResult extends AssignmentResult {
|
|||||||
this.targetTag = targetTag;
|
this.targetTag = targetTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the unassigned
|
|
||||||
*/
|
|
||||||
public int getUnassigned() {
|
public int getUnassigned() {
|
||||||
return unassigned;
|
return unassigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assignedTargets
|
|
||||||
*/
|
|
||||||
public List<Target> getAssignedTargets() {
|
public List<Target> getAssignedTargets() {
|
||||||
return assignedTargets;
|
return assignedTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the unassignedTargets
|
|
||||||
*/
|
|
||||||
public List<Target> getUnassignedTargets() {
|
public List<Target> getUnassignedTargets() {
|
||||||
return unassignedTargets;
|
return unassignedTargets;
|
||||||
}
|
}
|
||||||
@@ -13,11 +13,6 @@ package org.eclipse.hawkbit.repository.model;
|
|||||||
* status. A {@link Target} can have only one status. independent of the number
|
* status. A {@link Target} can have only one status. independent of the number
|
||||||
* of {@link UpdateAction}s that have to be applied.
|
* of {@link UpdateAction}s that have to be applied.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum TargetUpdateStatus {
|
public enum TargetUpdateStatus {
|
||||||
|
|
||||||
|
|||||||
@@ -30,32 +30,18 @@ public class TargetWithActionStatus {
|
|||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the target
|
|
||||||
*/
|
|
||||||
public Target getTarget() {
|
public Target getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the status
|
|
||||||
*/
|
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param target
|
|
||||||
* the target to set
|
|
||||||
*/
|
|
||||||
public void setTarget(final Target target) {
|
public void setTarget(final Target target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param status
|
|
||||||
* the status to set
|
|
||||||
*/
|
|
||||||
public void setStatus(final Status status) {
|
public void setStatus(final Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,23 +70,36 @@ public abstract class TenantAwareBaseEntity extends BaseEntity {
|
|||||||
return "BaseEntity [id=" + super.getId() + "]";
|
return "BaseEntity [id=" + super.getId() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tenant aware entities extend the equals/hashcode strategy with the tenant
|
||||||
|
* name. That would allow for instance in a multi-schema based data
|
||||||
|
* separation setup to have the same primary key for different entities of
|
||||||
|
* different tenants.
|
||||||
|
*
|
||||||
|
* @see org.eclipse.hawkbit.repository.model.BaseEntity#hashCode()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((tenant == null) ? 0 : tenant.hashCode());
|
result = prime * result + (tenant == null ? 0 : tenant.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tenant aware entities extend the equals/hashcode strategy with the tenant
|
||||||
|
* name. That would allow for instance in a multi-schema based data
|
||||||
|
* separation setup to have the same primary key for different entities of
|
||||||
|
* different tenants.
|
||||||
|
*
|
||||||
|
* @see org.eclipse.hawkbit.repository.model.BaseEntity#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof TenantAwareBaseEntity)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final TenantAwareBaseEntity other = (TenantAwareBaseEntity) obj;
|
final TenantAwareBaseEntity other = (TenantAwareBaseEntity) obj;
|
||||||
|
|||||||
@@ -19,18 +19,11 @@ import javax.persistence.UniqueConstraint;
|
|||||||
/**
|
/**
|
||||||
* A JPA entity which stores the tenant specific configuration.
|
* A JPA entity which stores the tenant specific configuration.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
||||||
"tenant" }, name = "uk_tenant_key"))
|
"tenant" }, name = "uk_tenant_key"))
|
||||||
public class TenantConfiguration extends TenantAwareBaseEntity implements Serializable {
|
public class TenantConfiguration extends TenantAwareBaseEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "conf_key", length = 128)
|
@Column(name = "conf_key", length = 128)
|
||||||
@@ -89,44 +82,23 @@ public class TenantConfiguration extends TenantAwareBaseEntity implements Serial
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = super.hashCode();
|
||||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) {
|
||||||
// code
|
if (!super.equals(obj)) {
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof TenantConfiguration)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final TenantConfiguration other = (TenantConfiguration) obj;
|
|
||||||
if (key == null) {
|
|
||||||
if (other.key != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!key.equals(other.key)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import javax.persistence.UniqueConstraint;
|
|||||||
* Tenant entity with meta data that is configured globally for the entire
|
* Tenant entity with meta data that is configured globally for the entire
|
||||||
* tenant. This entity is not tenant aware to allow the system to access it
|
* tenant. This entity is not tenant aware to allow the system to access it
|
||||||
* through the {@link EntityManager} even before the actual tenant exists.
|
* through the {@link EntityManager} even before the actual tenant exists.
|
||||||
*
|
*
|
||||||
* Entities owned by the tenant are based on {@link TenantAwareBaseEntity}.
|
* Entities owned by the tenant are based on {@link TenantAwareBaseEntity}.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -78,4 +78,23 @@ public class TenantMetaData extends BaseEntity {
|
|||||||
this.tenant = tenant;
|
this.tenant = tenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof TenantMetaData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,14 +139,6 @@ public final class RSQLUtility {
|
|||||||
this.enumType = enumType;
|
this.enumType = enumType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.springframework.data.jpa.domain.Specification#toPredicate(javax.
|
|
||||||
* persistence.criteria .Root, javax.persistence.criteria.CriteriaQuery,
|
|
||||||
* javax.persistence.criteria.CriteriaBuilder)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<T> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
public Predicate toPredicate(final Root<T> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ package org.eclipse.hawkbit.repository.specifications;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
|
||||||
import javax.persistence.criteria.Join;
|
import javax.persistence.criteria.Join;
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
import javax.persistence.criteria.ListJoin;
|
import javax.persistence.criteria.ListJoin;
|
||||||
import javax.persistence.criteria.Path;
|
import javax.persistence.criteria.Path;
|
||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
|
||||||
import javax.persistence.criteria.SetJoin;
|
import javax.persistence.criteria.SetJoin;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
@@ -33,9 +31,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifications class for {@link DistributionSet}s. The class provides Spring
|
* Specifications class for {@link DistributionSet}s. The class provides Spring
|
||||||
* Data JPQL Specifications
|
* Data JPQL Specifications.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class DistributionSetSpecification {
|
public final class DistributionSetSpecification {
|
||||||
@@ -53,16 +49,8 @@ public final class DistributionSetSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> isDeleted(final Boolean isDeleted) {
|
public static Specification<DistributionSet> isDeleted(final Boolean isDeleted) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<Boolean> get(DistributionSet_.deleted), isDeleted);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<Boolean> get(DistributionSet_.deleted), isDeleted);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,16 +63,8 @@ public final class DistributionSetSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> isCompleted(final Boolean isCompleted) {
|
public static Specification<DistributionSet> isCompleted(final Boolean isCompleted) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<Boolean> get(DistributionSet_.complete), isCompleted);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<Boolean> get(DistributionSet_.complete), isCompleted);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,21 +76,15 @@ public final class DistributionSetSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> byId(final Long distid) {
|
public static Specification<DistributionSet> byId(final Long distid) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final Predicate predicate = cb.equal(targetRoot.<Long> get(DistributionSet_.id), distid);
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT);
|
||||||
final CriteriaBuilder cb) {
|
targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT);
|
||||||
|
targetRoot.fetch(DistributionSet_.type, JoinType.LEFT);
|
||||||
|
query.distinct(true);
|
||||||
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<Long> get(DistributionSet_.id), distid);
|
return predicate;
|
||||||
targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT);
|
|
||||||
targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT);
|
|
||||||
targetRoot.fetch(DistributionSet_.type, JoinType.LEFT);
|
|
||||||
query.distinct(true);
|
|
||||||
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,20 +96,14 @@ public final class DistributionSetSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> byIds(final Collection<Long> distids) {
|
public static Specification<DistributionSet> byIds(final Collection<Long> distids) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final Predicate predicate = targetRoot.<Long> get(DistributionSet_.id).in(distids);
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT);
|
||||||
final CriteriaBuilder cb) {
|
targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT);
|
||||||
|
targetRoot.fetch(DistributionSet_.type, JoinType.LEFT);
|
||||||
final Predicate predicate = targetRoot.<Long> get(DistributionSet_.id).in(distids);
|
query.distinct(true);
|
||||||
targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT);
|
return predicate;
|
||||||
targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT);
|
|
||||||
targetRoot.fetch(DistributionSet_.type, JoinType.LEFT);
|
|
||||||
query.distinct(true);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,21 +115,10 @@ public final class DistributionSetSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> likeNameOrDescriptionOrVersion(final String subString) {
|
public static Specification<DistributionSet> likeNameOrDescriptionOrVersion(final String subString) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> cb.or(
|
||||||
@Override
|
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.name)), subString.toLowerCase()),
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.version)), subString.toLowerCase()),
|
||||||
final CriteriaBuilder cb) {
|
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.description)), subString.toLowerCase()));
|
||||||
final Predicate predicate = cb
|
|
||||||
.or(cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.name)), subString.toLowerCase()),
|
|
||||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.version)),
|
|
||||||
subString.toLowerCase()),
|
|
||||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.description)),
|
|
||||||
subString.toLowerCase()));
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,19 +133,13 @@ public final class DistributionSetSpecification {
|
|||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> hasTags(final Collection<String> tagNames,
|
public static Specification<DistributionSet> hasTags(final Collection<String> tagNames,
|
||||||
final Boolean selectDSWithNoTag) {
|
final Boolean selectDSWithNoTag) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final SetJoin<DistributionSet, DistributionSetTag> tags = targetRoot.join(DistributionSet_.tags,
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
JoinType.LEFT);
|
||||||
final CriteriaBuilder cb) {
|
final Predicate predicate = getPredicate(tags, tagNames, selectDSWithNoTag, cb);
|
||||||
final SetJoin<DistributionSet, DistributionSetTag> tags = targetRoot.join(DistributionSet_.tags,
|
query.distinct(true);
|
||||||
JoinType.LEFT);
|
return predicate;
|
||||||
final Predicate predicate = getPredicate(tags, tagNames, selectDSWithNoTag, cb);
|
|
||||||
query.distinct(true);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate getPredicate(final SetJoin<DistributionSet, DistributionSetTag> tags,
|
private static Predicate getPredicate(final SetJoin<DistributionSet, DistributionSetTag> tags,
|
||||||
@@ -218,20 +169,10 @@ public final class DistributionSetSpecification {
|
|||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> equalsNameAndVersionIgnoreCase(final String name,
|
public static Specification<DistributionSet> equalsNameAndVersionIgnoreCase(final String name,
|
||||||
final String version) {
|
final String version) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> cb.and(
|
||||||
@Override
|
cb.equal(cb.lower(targetRoot.<String> get(DistributionSet_.name)), name.toLowerCase()),
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
cb.equal(cb.lower(targetRoot.<String> get(DistributionSet_.version)), version.toLowerCase()));
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.and(
|
|
||||||
// formatter:off
|
|
||||||
cb.equal(cb.lower(targetRoot.<String> get(DistributionSet_.name)), name.toLowerCase()),
|
|
||||||
cb.equal(cb.lower(targetRoot.<String> get(DistributionSet_.version)), version.toLowerCase()));
|
|
||||||
// formatter:on
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -243,16 +184,8 @@ public final class DistributionSetSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> byType(final DistributionSetType type) {
|
public static Specification<DistributionSet> byType(final DistributionSetType type) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<DistributionSetType> get(DistributionSet_.type), type);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<DistributionSetType> get(DistributionSet_.type), type);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,18 +196,12 @@ public final class DistributionSetSpecification {
|
|||||||
* installed to the given targetId
|
* installed to the given targetId
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> installedTarget(final String installedTargetId) {
|
public static Specification<DistributionSet> installedTarget(final String installedTargetId) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (dsRoot, query, cb) -> {
|
||||||
@Override
|
final ListJoin<DistributionSet, TargetInfo> installedTargetJoin = dsRoot
|
||||||
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
.join(DistributionSet_.installedAtTargets, JoinType.INNER);
|
||||||
final CriteriaBuilder cb) {
|
final Join<TargetInfo, Target> targetJoin = installedTargetJoin.join(TargetInfo_.target);
|
||||||
final ListJoin<DistributionSet, TargetInfo> installedTargetJoin = dsRoot
|
return cb.equal(targetJoin.get(Target_.controllerId), installedTargetId);
|
||||||
.join(DistributionSet_.installedAtTargets, JoinType.INNER);
|
|
||||||
final Join<TargetInfo, Target> targetJoin = installedTargetJoin.join(TargetInfo_.target);
|
|
||||||
return cb.equal(targetJoin.get(Target_.controllerId), installedTargetId);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -285,16 +212,11 @@ public final class DistributionSetSpecification {
|
|||||||
* assigned to the given targetId
|
* assigned to the given targetId
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> assignedTarget(final String assignedTargetId) {
|
public static Specification<DistributionSet> assignedTarget(final String assignedTargetId) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
return (dsRoot, query, cb) -> {
|
||||||
@Override
|
final ListJoin<DistributionSet, Target> assignedTargetJoin = dsRoot.join(DistributionSet_.assignedToTargets,
|
||||||
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
JoinType.INNER);
|
||||||
final CriteriaBuilder cb) {
|
return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId);
|
||||||
final ListJoin<DistributionSet, Target> assignedTargetJoin = dsRoot
|
|
||||||
.join(DistributionSet_.assignedToTargets, JoinType.INNER);
|
|
||||||
return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,22 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.specifications;
|
package org.eclipse.hawkbit.repository.specifications;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
|
||||||
import javax.persistence.criteria.Predicate;
|
|
||||||
import javax.persistence.criteria.Root;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType_;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType_;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Specifications class for {@link DistributionSetType}s. The class provides
|
||||||
*
|
* Spring Data JPQL Specifications.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class DistributionSetTypeSpecification {
|
public final class DistributionSetTypeSpecification {
|
||||||
private DistributionSetTypeSpecification() {
|
private DistributionSetTypeSpecification() {
|
||||||
@@ -40,16 +32,7 @@ public final class DistributionSetTypeSpecification {
|
|||||||
* @return the {@link DistributionSetType} {@link Specification}
|
* @return the {@link DistributionSetType} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSetType> isDeleted(final Boolean isDeleted) {
|
public static Specification<DistributionSetType> isDeleted(final Boolean isDeleted) {
|
||||||
final Specification<DistributionSetType> spec = new Specification<DistributionSetType>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<Boolean> get(DistributionSetType_.deleted), isDeleted);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<DistributionSetType> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<Boolean> get(DistributionSetType_.deleted), isDeleted);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,16 +45,7 @@ public final class DistributionSetTypeSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSetType> byId(final Long distid) {
|
public static Specification<DistributionSetType> byId(final Long distid) {
|
||||||
final Specification<DistributionSetType> spec = new Specification<DistributionSetType>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<Long> get(DistributionSetType_.id), distid);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<DistributionSetType> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<Long> get(DistributionSetType_.id), distid);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,16 +58,7 @@ public final class DistributionSetTypeSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSetType> byName(final String name) {
|
public static Specification<DistributionSetType> byName(final String name) {
|
||||||
final Specification<DistributionSetType> spec = new Specification<DistributionSetType>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<String> get(DistributionSetType_.name), name);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<DistributionSetType> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<String> get(DistributionSetType_.name), name);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,16 +71,7 @@ public final class DistributionSetTypeSpecification {
|
|||||||
* @return the {@link DistributionSet} {@link Specification}
|
* @return the {@link DistributionSet} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSetType> byKey(final String key) {
|
public static Specification<DistributionSetType> byKey(final String key) {
|
||||||
final Specification<DistributionSetType> spec = new Specification<DistributionSetType>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<String> get(DistributionSetType_.key), key);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<DistributionSetType> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<String> get(DistributionSetType_.key), key);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.specifications;
|
package org.eclipse.hawkbit.repository.specifications;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
|
||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
@@ -22,8 +19,6 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
* Specifications class for {@link SoftwareModule}s. The class provides Spring
|
* Specifications class for {@link SoftwareModule}s. The class provides Spring
|
||||||
* Data JPQL Specifications
|
* Data JPQL Specifications
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class SoftwareModuleSpecification {
|
public final class SoftwareModuleSpecification {
|
||||||
private SoftwareModuleSpecification() {
|
private SoftwareModuleSpecification() {
|
||||||
@@ -39,38 +34,21 @@ public final class SoftwareModuleSpecification {
|
|||||||
* @return the {@link SoftwareModule} {@link Specification}
|
* @return the {@link SoftwareModule} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<SoftwareModule> byId(final Long moduleId) {
|
public static Specification<SoftwareModule> byId(final Long moduleId) {
|
||||||
final Specification<SoftwareModule> spec = new Specification<SoftwareModule>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final Predicate predicate = cb.equal(targetRoot.<Long> get(SoftwareModule_.id), moduleId);
|
||||||
public Predicate toPredicate(final Root<SoftwareModule> targetRoot, final CriteriaQuery<?> query,
|
targetRoot.fetch(SoftwareModule_.type);
|
||||||
final CriteriaBuilder cb) {
|
return predicate;
|
||||||
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<Long> get(SoftwareModule_.id), moduleId);
|
|
||||||
targetRoot.fetch(SoftwareModule_.type);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Specification} for retrieving {@link SoftwareModule}s by its
|
* {@link Specification} for retrieving {@link SoftwareModule}s where its
|
||||||
* DELETED attribute.
|
* DELETED attribute is false.
|
||||||
*
|
*
|
||||||
* @param isDeleted
|
|
||||||
* TRUE/FALSE are compared to the attribute DELETED. If NULL the
|
|
||||||
* attribute is ignored
|
|
||||||
* @return the {@link SoftwareModule} {@link Specification}
|
* @return the {@link SoftwareModule} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<SoftwareModule> isDeletedFalse() {
|
public static Specification<SoftwareModule> isDeletedFalse() {
|
||||||
final Specification<SoftwareModule> spec = new Specification<SoftwareModule>() {
|
return (swRoot, query, cb) -> cb.equal(swRoot.<Boolean> get(SoftwareModule_.deleted), Boolean.FALSE);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<SoftwareModule> swRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.equal(swRoot.<Boolean> get(SoftwareModule_.deleted), Boolean.FALSE);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,18 +60,9 @@ public final class SoftwareModuleSpecification {
|
|||||||
* @return the {@link SoftwareModule} {@link Specification}
|
* @return the {@link SoftwareModule} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<SoftwareModule> likeNameOrVersion(final String subString) {
|
public static Specification<SoftwareModule> likeNameOrVersion(final String subString) {
|
||||||
final Specification<SoftwareModule> spec = new Specification<SoftwareModule>() {
|
return (targetRoot, query, cb) -> cb.or(
|
||||||
@Override
|
cb.like(cb.lower(targetRoot.<String> get(SoftwareModule_.name)), subString.toLowerCase()),
|
||||||
public Predicate toPredicate(final Root<SoftwareModule> targetRoot, final CriteriaQuery<?> query,
|
cb.like(cb.lower(targetRoot.<String> get(SoftwareModule_.version)), subString.toLowerCase()));
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.or(
|
|
||||||
cb.like(cb.lower(targetRoot.<String> get(SoftwareModule_.name)), subString.toLowerCase()),
|
|
||||||
cb.like(cb.lower(targetRoot.<String> get(SoftwareModule_.version)), subString.toLowerCase()));
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,16 +74,7 @@ public final class SoftwareModuleSpecification {
|
|||||||
* @return the {@link SoftwareModule} {@link Specification}
|
* @return the {@link SoftwareModule} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<SoftwareModule> equalType(final SoftwareModuleType type) {
|
public static Specification<SoftwareModule> equalType(final SoftwareModuleType type) {
|
||||||
final Specification<SoftwareModule> spec = new Specification<SoftwareModule>() {
|
return (targetRoot, query, cb) -> cb.equal(targetRoot.<SoftwareModuleType> get(SoftwareModule_.type), type);
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<SoftwareModule> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.equal(targetRoot.<SoftwareModuleType> get(SoftwareModule_.type), type);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,17 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.specifications;
|
package org.eclipse.hawkbit.repository.specifications;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
|
||||||
import javax.persistence.criteria.Predicate;
|
|
||||||
import javax.persistence.criteria.Root;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery_;
|
import org.eclipse.hawkbit.repository.model.TargetFilterQuery_;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Specifications class for {@link TargetFilterQuery}s. The class provides
|
||||||
|
* Spring Data JPQL Specifications.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TargetFilterQuerySpecification {
|
public class TargetFilterQuerySpecification {
|
||||||
@@ -27,16 +23,9 @@ public class TargetFilterQuerySpecification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Specification<TargetFilterQuery> likeName(final String searchText) {
|
public static Specification<TargetFilterQuery> likeName(final String searchText) {
|
||||||
final Specification<TargetFilterQuery> spec = new Specification<TargetFilterQuery>() {
|
return (targetFilterQueryRoot, query, cb) -> {
|
||||||
@Override
|
final String searchTextToLower = searchText.toLowerCase();
|
||||||
public Predicate toPredicate(final Root<TargetFilterQuery> targetFilterQueryRoot,
|
return cb.like(cb.lower(targetFilterQueryRoot.get(TargetFilterQuery_.name)), searchTextToLower);
|
||||||
final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
|
||||||
final String searchTextToLower = searchText.toLowerCase();
|
|
||||||
final Predicate predicate = cb.like(cb.lower(targetFilterQueryRoot.get(TargetFilterQuery_.name)),
|
|
||||||
searchTextToLower);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
|
||||||
import javax.persistence.criteria.Join;
|
import javax.persistence.criteria.Join;
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
import javax.persistence.criteria.Path;
|
import javax.persistence.criteria.Path;
|
||||||
@@ -36,8 +35,6 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
* Specifications class for {@link Target}s. The class provides Spring Data JPQL
|
* Specifications class for {@link Target}s. The class provides Spring Data JPQL
|
||||||
* Specifications.
|
* Specifications.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class TargetSpecifications {
|
public final class TargetSpecifications {
|
||||||
private TargetSpecifications() {
|
private TargetSpecifications() {
|
||||||
@@ -54,18 +51,12 @@ public final class TargetSpecifications {
|
|||||||
* @return the {@link Target} {@link Specification}
|
* @return the {@link Target} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<Target> byControllerIdWithStatusAndTagsInJoin(final Collection<String> controllerIDs) {
|
public static Specification<Target> byControllerIdWithStatusAndTagsInJoin(final Collection<String> controllerIDs) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
targetRoot.fetch(Target_.tags, JoinType.LEFT);
|
||||||
final CriteriaBuilder cb) {
|
query.distinct(true);
|
||||||
final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
|
return predicate;
|
||||||
targetRoot.fetch(Target_.tags, JoinType.LEFT);
|
|
||||||
query.distinct(true);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,18 +70,12 @@ public final class TargetSpecifications {
|
|||||||
*/
|
*/
|
||||||
public static Specification<Target> byControllerIdWithStatusAndAssignedInJoin(
|
public static Specification<Target> byControllerIdWithStatusAndAssignedInJoin(
|
||||||
final Collection<String> controllerIDs) {
|
final Collection<String> controllerIDs) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
|
|
||||||
final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
|
final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
|
||||||
targetRoot.fetch(Target_.assignedDistributionSet);
|
targetRoot.fetch(Target_.assignedDistributionSet);
|
||||||
return predicate;
|
return predicate;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,24 +91,18 @@ public final class TargetSpecifications {
|
|||||||
*/
|
*/
|
||||||
public static Specification<Target> hasTargetUpdateStatus(final Collection<TargetUpdateStatus> updateStatus,
|
public static Specification<Target> hasTargetUpdateStatus(final Collection<TargetUpdateStatus> updateStatus,
|
||||||
final boolean fetch) {
|
final boolean fetch) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
if (!query.getResultType().isAssignableFrom(Long.class)) {
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
if (fetch) {
|
||||||
final CriteriaBuilder cb) {
|
targetRoot.fetch(Target_.targetInfo);
|
||||||
if (!query.getResultType().isAssignableFrom(Long.class)) {
|
} else {
|
||||||
if (fetch) {
|
targetRoot.join(Target_.targetInfo);
|
||||||
targetRoot.fetch(Target_.targetInfo);
|
|
||||||
} else {
|
|
||||||
targetRoot.join(Target_.targetInfo);
|
|
||||||
}
|
|
||||||
return targetRoot.get(Target_.targetInfo).get(TargetInfo_.updateStatus).in(updateStatus);
|
|
||||||
}
|
}
|
||||||
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
return targetRoot.get(Target_.targetInfo).get(TargetInfo_.updateStatus).in(updateStatus);
|
||||||
return targetInfoJoin.get(TargetInfo_.updateStatus).in(updateStatus);
|
|
||||||
}
|
}
|
||||||
|
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
||||||
|
return targetInfoJoin.get(TargetInfo_.updateStatus).in(updateStatus);
|
||||||
};
|
};
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,18 +114,11 @@ public final class TargetSpecifications {
|
|||||||
* @return the {@link Target} {@link Specification}
|
* @return the {@link Target} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<Target> likeNameOrDescriptionOrIp(final String searchText) {
|
public static Specification<Target> likeNameOrDescriptionOrIp(final String searchText) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final String searchTextToLower = searchText.toLowerCase();
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
return cb.or(cb.like(cb.lower(targetRoot.get(Target_.name)), searchTextToLower),
|
||||||
final CriteriaBuilder cb) {
|
cb.like(cb.lower(targetRoot.get(Target_.description)), searchTextToLower));
|
||||||
final String searchTextToLower = searchText.toLowerCase();
|
|
||||||
final Predicate predicate = cb.or(cb.like(cb.lower(targetRoot.get(Target_.name)), searchTextToLower),
|
|
||||||
cb.like(cb.lower(targetRoot.get(Target_.description)), searchTextToLower));
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,21 +130,14 @@ public final class TargetSpecifications {
|
|||||||
* @return the {@link Target} {@link Specification}
|
* @return the {@link Target} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<Target> hasInstalledOrAssignedDistributionSet(@NotNull final Long distributionId) {
|
public static Specification<Target> hasInstalledOrAssignedDistributionSet(@NotNull final Long distributionId) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
return cb.or(
|
||||||
final CriteriaBuilder cb) {
|
cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
|
||||||
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
distributionId),
|
||||||
final Predicate predicate = cb.or(
|
cb.equal(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet).get(DistributionSet_.id),
|
||||||
cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
|
distributionId));
|
||||||
distributionId),
|
|
||||||
cb.equal(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet)
|
|
||||||
.get(DistributionSet_.id), distributionId));
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,18 +152,11 @@ public final class TargetSpecifications {
|
|||||||
*/
|
*/
|
||||||
public static Specification<Target> hasControllerIdAndAssignedDistributionSetIdNot(final List<String> tIDs,
|
public static Specification<Target> hasControllerIdAndAssignedDistributionSetIdNot(final List<String> tIDs,
|
||||||
@NotNull final Long distributionId) {
|
@NotNull final Long distributionId) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
return (targetRoot, query, cb) -> cb
|
||||||
@Override
|
.and(targetRoot.get(Target_.controllerId).in(tIDs),
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
final Predicate predicate = cb.and(targetRoot.get(Target_.controllerId).in(tIDs),
|
|
||||||
cb.or(cb.notEqual(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet)
|
cb.or(cb.notEqual(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet)
|
||||||
.get(DistributionSet_.id), distributionId),
|
.get(DistributionSet_.id), distributionId),
|
||||||
cb.isNull(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet))));
|
cb.isNull(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet))));
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,16 +170,11 @@ public final class TargetSpecifications {
|
|||||||
* @return the {@link Target} {@link Specification}
|
* @return the {@link Target} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<Target> hasTags(final String[] tagNames, final Boolean selectTargetWithNoTag) {
|
public static Specification<Target> hasTags(final String[] tagNames, final Boolean selectTargetWithNoTag) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final Predicate predicate = getPredicate(targetRoot, cb, selectTargetWithNoTag, tagNames);
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
query.distinct(true);
|
||||||
final CriteriaBuilder cb) {
|
return predicate;
|
||||||
final Predicate predicate = getPredicate(targetRoot, cb, selectTargetWithNoTag, tagNames);
|
|
||||||
query.distinct(true);
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate getPredicate(final Root<Target> targetRoot, final CriteriaBuilder cb,
|
private static Predicate getPredicate(final Root<Target> targetRoot, final CriteriaBuilder cb,
|
||||||
@@ -248,15 +201,9 @@ public final class TargetSpecifications {
|
|||||||
* @return the {@link Target} {@link Specification}
|
* @return the {@link Target} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<Target> hasAssignedDistributionSet(final Long distributionSetId) {
|
public static Specification<Target> hasAssignedDistributionSet(final Long distributionSetId) {
|
||||||
return new Specification<Target>() {
|
return (targetRoot, query, cb) -> cb.equal(
|
||||||
@Override
|
targetRoot.<DistributionSet> get(Target_.assignedDistributionSet).get(DistributionSet_.id),
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
distributionSetId);
|
||||||
final CriteriaBuilder cb) {
|
|
||||||
return cb.equal(
|
|
||||||
targetRoot.<DistributionSet> get(Target_.assignedDistributionSet).get(DistributionSet_.id),
|
|
||||||
distributionSetId);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,14 +215,10 @@ public final class TargetSpecifications {
|
|||||||
* @return the {@link Target} {@link Specification}
|
* @return the {@link Target} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<Target> hasInstalledDistributionSet(final Long distributionSetId) {
|
public static Specification<Target> hasInstalledDistributionSet(final Long distributionSetId) {
|
||||||
return new Specification<Target>() {
|
return (targetRoot, query, cb) -> {
|
||||||
@Override
|
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
return cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
|
||||||
final CriteriaBuilder cb) {
|
distributionSetId);
|
||||||
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
|
||||||
return cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
|
|
||||||
distributionSetId);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class TestDataUtil {
|
|||||||
return distributionSetManagement.createDistributionSet(
|
return distributionSetManagement.createDistributionSet(
|
||||||
buildDistributionSet(suffix != null && suffix.length() > 0 ? suffix : "DS", version,
|
buildDistributionSet(suffix != null && suffix.length() > 0 ? suffix : "DS", version,
|
||||||
findOrCreateDistributionSetType(distributionSetManagement, "ecl_os_app_jvm",
|
findOrCreateDistributionSetType(distributionSetManagement, "ecl_os_app_jvm",
|
||||||
"OC mandatory App/JVM optional", mand, opt),
|
"OS mandatory App/JVM optional", mand, opt),
|
||||||
os, jvm, ah).setRequiredMigrationStep(isRequiredMigrationStep));
|
os, jvm, ah).setRequiredMigrationStep(isRequiredMigrationStep));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public class TestDataUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<DistributionSetTag> generateDistributionSetTags(final int number) {
|
public static List<DistributionSetTag> generateDistributionSetTags(final int number) {
|
||||||
final List<DistributionSetTag> result = new ArrayList<DistributionSetTag>();
|
final List<DistributionSetTag> result = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < number; i++) {
|
for (int i = 0; i < number; i++) {
|
||||||
result.add(new DistributionSetTag("tag" + i, "tagdesc" + i, "" + i));
|
result.add(new DistributionSetTag("tag" + i, "tagdesc" + i, "" + i));
|
||||||
|
|||||||
@@ -33,12 +33,10 @@ public class ActionTest {
|
|||||||
final Action timeforcedAction = new Action();
|
final Action timeforcedAction = new Action();
|
||||||
timeforcedAction.setActionType(ActionType.TIMEFORCED);
|
timeforcedAction.setActionType(ActionType.TIMEFORCED);
|
||||||
timeforcedAction.setForcedTime(timeForceTimeAt);
|
timeforcedAction.setForcedTime(timeForceTimeAt);
|
||||||
final int knownHashCode = timeforcedAction.hashCode();
|
|
||||||
assertThat(timeforcedAction.isForce()).isFalse();
|
assertThat(timeforcedAction.isForce()).isFalse();
|
||||||
|
|
||||||
// wait until timeforce time is hit
|
// wait until timeforce time is hit
|
||||||
Thread.sleep(sleepTime + 100);
|
Thread.sleep(sleepTime + 100);
|
||||||
assertThat(timeforcedAction.isForce()).isTrue();
|
assertThat(timeforcedAction.isForce()).isTrue();
|
||||||
assertThat(timeforcedAction.hashCode()).isNotEqualTo(knownHashCode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -37,7 +39,7 @@ public class ArtifactManagementNoMongoDbTest extends AbstractIntegrationTest {
|
|||||||
System.setProperty("spring.data.mongodb.port", "1020");
|
System.setProperty("spring.data.mongodb.port", "1020");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ArtifactUploadFailedException.class)
|
@Test
|
||||||
@Description("Checks if the expected ArtifactUploadFailedException is thrown in case of MongoDB down")
|
@Description("Checks if the expected ArtifactUploadFailedException is thrown in case of MongoDB down")
|
||||||
public void createLocalArtifactWithMongoDbDown() throws IOException {
|
public void createLocalArtifactWithMongoDbDown() throws IOException {
|
||||||
SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
|
SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
|
||||||
@@ -46,7 +48,12 @@ public class ArtifactManagementNoMongoDbTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
try {
|
||||||
|
artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||||
|
fail("Should not have worked with MongoDb down.");
|
||||||
|
} catch (final ArtifactUploadFailedException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,11 +352,16 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
artifactManagement.loadLocalArtifactBinary(result).getFileInputStream()));
|
artifactManagement.loadLocalArtifactBinary(result).getFileInputStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InsufficientPermissionException.class)
|
@Test
|
||||||
@WithUser(allSpPermissions = true, removeFromAllPermission = { SpPermission.DOWNLOAD_REPOSITORY_ARTIFACT })
|
@WithUser(allSpPermissions = true, removeFromAllPermission = { SpPermission.DOWNLOAD_REPOSITORY_ARTIFACT })
|
||||||
@Description("Trys and fails to load an artifact without required permission. Checks if expected InsufficientPermissionException is thrown.")
|
@Description("Trys and fails to load an artifact without required permission. Checks if expected InsufficientPermissionException is thrown.")
|
||||||
public void loadLocalArtifactBinaryWithoutDownloadArtifactThrowsPermissionDenied() {
|
public void loadLocalArtifactBinaryWithoutDownloadArtifactThrowsPermissionDenied() {
|
||||||
artifactManagement.loadLocalArtifactBinary(new LocalArtifact());
|
try {
|
||||||
|
artifactManagement.loadLocalArtifactBinary(new LocalArtifact());
|
||||||
|
fail("Should not have worked with missing permission.");
|
||||||
|
} catch (final InsufficientPermissionException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
|
|||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
Target savedTarget = targetManagement.createTarget(target);
|
Target savedTarget = targetManagement.createTarget(target);
|
||||||
|
|
||||||
final List<Target> toAssign = new ArrayList<Target>();
|
final List<Target> toAssign = new ArrayList<>();
|
||||||
toAssign.add(savedTarget);
|
toAssign.add(savedTarget);
|
||||||
|
|
||||||
assertThat(savedTarget.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
|
assertThat(savedTarget.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
@@ -75,7 +75,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Register a controller which not exist")
|
@Description("Register a controller which does not exist")
|
||||||
public void testfindOrRegisterTargetIfItDoesNotexist() {
|
public void testfindOrRegisterTargetIfItDoesNotexist() {
|
||||||
final Target target = controllerManagament.findOrRegisterTargetIfItDoesNotexist("AA", null);
|
final Target target = controllerManagament.findOrRegisterTargetIfItDoesNotexist("AA", null);
|
||||||
assertThat(target).as("target should not be null").isNotNull();
|
assertThat(target).as("target should not be null").isNotNull();
|
||||||
@@ -84,11 +84,12 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
|
|||||||
assertThat(target).as("Target should be the equals").isEqualTo(sameTarget);
|
assertThat(target).as("Target should be the equals").isEqualTo(sameTarget);
|
||||||
assertThat(targetRepository.count()).as("Only 1 target should be registred").isEqualTo(1L);
|
assertThat(targetRepository.count()).as("Only 1 target should be registred").isEqualTo(1L);
|
||||||
|
|
||||||
|
// throws exception
|
||||||
try {
|
try {
|
||||||
controllerManagament.findOrRegisterTargetIfItDoesNotexist("", null);
|
controllerManagament.findOrRegisterTargetIfItDoesNotexist("", null);
|
||||||
fail("target with empty controller id should not be registred");
|
fail("should fail as target does not exist");
|
||||||
} catch (final ConstraintViolationException e) {
|
} catch (final ConstraintViolationException e) {
|
||||||
// ok
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
|
|||||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
Target savedTarget = targetManagement.createTarget(target);
|
Target savedTarget = targetManagement.createTarget(target);
|
||||||
final List<Target> toAssign = new ArrayList<Target>();
|
final List<Target> toAssign = new ArrayList<>();
|
||||||
toAssign.add(savedTarget);
|
toAssign.add(savedTarget);
|
||||||
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedTargets().iterator().next();
|
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedTargets().iterator().next();
|
||||||
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||||
@@ -124,7 +125,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
|
|||||||
final ActionStatus actionStatusMessage3 = new ActionStatus(savedAction, Action.Status.FINISHED,
|
final ActionStatus actionStatusMessage3 = new ActionStatus(savedAction, Action.Status.FINISHED,
|
||||||
System.currentTimeMillis());
|
System.currentTimeMillis());
|
||||||
actionStatusMessage3.addMessage("finish");
|
actionStatusMessage3.addMessage("finish");
|
||||||
savedAction = controllerManagament.addUpdateActionStatus(actionStatusMessage3, savedAction);
|
controllerManagament.addUpdateActionStatus(actionStatusMessage3, savedAction);
|
||||||
|
|
||||||
targetManagement.findTargetByControllerID("Rabbit").getTargetInfo().getUpdateStatus();
|
targetManagement.findTargetByControllerID("Rabbit").getTargetInfo().getUpdateStatus();
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
|||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.fest.assertions.core.Condition;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
@@ -44,15 +45,12 @@ import ru.yandex.qatools.allure.annotations.Features;
|
|||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link SoftwareManagement} test focused on {@link DistributionSet} and
|
* {@link DistributionSetManagement} tests.
|
||||||
* {@link DistributionSetType} related stuff.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Features("Component Tests - Repository")
|
@Features("Component Tests - Repository")
|
||||||
@Stories("Software Management")
|
@Stories("DistributionSet Management")
|
||||||
public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
public class DistributionSetManagementTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the successfull module update of unused distribution set type which is in fact allowed.")
|
@Description("Tests the successfull module update of unused distribution set type which is in fact allowed.")
|
||||||
@@ -102,7 +100,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.isEqualTo("test123");
|
.isEqualTo("test123");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = EntityReadOnlyException.class)
|
@Test
|
||||||
@Description("Tests the unsuccessfull update of used distribution set type (module addition).")
|
@Description("Tests the unsuccessfull update of used distribution set type (module addition).")
|
||||||
public void addModuleToAssignedDistributionSetTypeFails() {
|
public void addModuleToAssignedDistributionSetTypeFails() {
|
||||||
final DistributionSetType nonUpdatableType = distributionSetManagement
|
final DistributionSetType nonUpdatableType = distributionSetManagement
|
||||||
@@ -113,10 +111,17 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", nonUpdatableType, null));
|
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", nonUpdatableType, null));
|
||||||
|
|
||||||
nonUpdatableType.addMandatoryModuleType(osType);
|
nonUpdatableType.addMandatoryModuleType(osType);
|
||||||
distributionSetManagement.updateDistributionSetType(nonUpdatableType);
|
|
||||||
|
try {
|
||||||
|
distributionSetManagement.updateDistributionSetType(nonUpdatableType);
|
||||||
|
fail("Should not have worked as DS is in use.");
|
||||||
|
} catch (final EntityReadOnlyException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = EntityReadOnlyException.class)
|
@Test
|
||||||
@Description("Tests the unsuccessfull update of used distribution set type (module removal).")
|
@Description("Tests the unsuccessfull update of used distribution set type (module removal).")
|
||||||
public void removeModuleToAssignedDistributionSetTypeFails() {
|
public void removeModuleToAssignedDistributionSetTypeFails() {
|
||||||
DistributionSetType nonUpdatableType = distributionSetManagement
|
DistributionSetType nonUpdatableType = distributionSetManagement
|
||||||
@@ -130,7 +135,12 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", nonUpdatableType, null));
|
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", nonUpdatableType, null));
|
||||||
|
|
||||||
nonUpdatableType.removeModuleType(osType.getId());
|
nonUpdatableType.removeModuleType(osType.getId());
|
||||||
nonUpdatableType = distributionSetManagement.updateDistributionSetType(nonUpdatableType);
|
try {
|
||||||
|
distributionSetManagement.updateDistributionSetType(nonUpdatableType);
|
||||||
|
fail("Should not have worked as DS is in use.");
|
||||||
|
} catch (final EntityReadOnlyException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -152,22 +162,68 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.createDistributionSetType(new DistributionSetType("softdeleted", "to be deletd", ""));
|
.createDistributionSetType(new DistributionSetType("softdeleted", "to be deletd", ""));
|
||||||
|
|
||||||
assertThat(distributionSetTypeRepository.findAll()).contains(softDelete);
|
assertThat(distributionSetTypeRepository.findAll()).contains(softDelete);
|
||||||
final DistributionSet dsNewType = distributionSetManagement
|
distributionSetManagement.createDistributionSet(new DistributionSet("newtypesoft", "1", "", softDelete, null));
|
||||||
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", softDelete, null));
|
|
||||||
|
|
||||||
distributionSetManagement.deleteDistributionSetType(softDelete);
|
distributionSetManagement.deleteDistributionSetType(softDelete);
|
||||||
assertThat(distributionSetManagement.findDistributionSetTypeByKey("softdeleted").isDeleted()).isEqualTo(true);
|
assertThat(distributionSetManagement.findDistributionSetTypeByKey("softdeleted").isDeleted()).isEqualTo(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: kzimmerm: test N+1
|
@Test
|
||||||
|
|
||||||
@Test(expected = EntityAlreadyExistsException.class)
|
|
||||||
@Description("Ensures that it is not possible to create a DS that already exists (unique constraint is on name,version for DS).")
|
@Description("Ensures that it is not possible to create a DS that already exists (unique constraint is on name,version for DS).")
|
||||||
public void createDuplicateDistributionSetsFailsWithException() {
|
public void createDuplicateDistributionSetsFailsWithException() {
|
||||||
TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement);
|
TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement);
|
||||||
|
|
||||||
TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement);
|
try {
|
||||||
|
TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement);
|
||||||
|
fail("Should not have worked as DS with same UK already exists.");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that a DS is of default type if not specified explicitly at creation time.")
|
||||||
|
public void createDistributionSetWithImplicitType() {
|
||||||
|
final DistributionSet set = distributionSetManagement
|
||||||
|
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", null, null));
|
||||||
|
|
||||||
|
assertThat(set.getType()).as("Type should be equal to default type of tenant")
|
||||||
|
.isEqualTo(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that multiple DS are of default type if not specified explicitly at creation time.")
|
||||||
|
public void createMultipleDistributionSetsWithImplicitType() {
|
||||||
|
|
||||||
|
List<DistributionSet> sets = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
sets.add(new DistributionSet("another DS" + i, "X" + i, "", null, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
sets = distributionSetManagement.createDistributionSets(sets);
|
||||||
|
|
||||||
|
assertThat(sets).as("Type should be equal to default type of tenant").are(new Condition<DistributionSet>() {
|
||||||
|
@Override
|
||||||
|
public boolean matches(final DistributionSet value) {
|
||||||
|
return value.getType().equals(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that a DS entity cannot be used for creation.")
|
||||||
|
public void createDistributionSetFailsOnExistingEntity() {
|
||||||
|
final DistributionSet set = distributionSetManagement
|
||||||
|
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", null, null));
|
||||||
|
|
||||||
|
try {
|
||||||
|
distributionSetManagement.createDistributionSet(set);
|
||||||
|
fail("Should not have worked to create based on a persisted entity.");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -244,17 +300,22 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = DistributionSetTypeUndefinedException.class)
|
@Test
|
||||||
@Description("Ensures that it is not possible to add a software module to a set that has no type defined.")
|
@Description("Ensures that it is not possible to add a software module to a set that has no type defined.")
|
||||||
public void updateDistributionSetModuleWithUndefinedTypeFails() {
|
public void updateDistributionSetModuleWithUndefinedTypeFails() {
|
||||||
final DistributionSet testSet = new DistributionSet();
|
final DistributionSet testSet = new DistributionSet();
|
||||||
final SoftwareModule module = new SoftwareModule(appType, "agent-hub2", "1.0.5", null, "");
|
final SoftwareModule module = new SoftwareModule(appType, "agent-hub2", "1.0.5", null, "");
|
||||||
|
|
||||||
// update data
|
// update data
|
||||||
testSet.addModule(module);
|
try {
|
||||||
|
testSet.addModule(module);
|
||||||
|
fail("Should not have worked as DS type is undefined.");
|
||||||
|
} catch (final DistributionSetTypeUndefinedException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = UnsupportedSoftwareModuleForThisDistributionSetException.class)
|
@Test
|
||||||
@Description("Ensures that it is not possible to add a software module that is not defined of the DS's type.")
|
@Description("Ensures that it is not possible to add a software module that is not defined of the DS's type.")
|
||||||
public void updateDistributionSetUnsupportedModuleFails() {
|
public void updateDistributionSetUnsupportedModuleFails() {
|
||||||
final DistributionSet set = new DistributionSet("agent-hub2", "1.0.5", "desc",
|
final DistributionSet set = new DistributionSet("agent-hub2", "1.0.5", "desc",
|
||||||
@@ -262,7 +323,12 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
final SoftwareModule module = new SoftwareModule(appType, "agent-hub2", "1.0.5", null, "");
|
final SoftwareModule module = new SoftwareModule(appType, "agent-hub2", "1.0.5", null, "");
|
||||||
|
|
||||||
// update data
|
// update data
|
||||||
set.addModule(module);
|
try {
|
||||||
|
set.addModule(module);
|
||||||
|
fail("Should not have worked as module type is not in DS type.");
|
||||||
|
} catch (final UnsupportedSoftwareModuleForThisDistributionSetException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -561,7 +627,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
|
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
|
||||||
|
|
||||||
// combine deleted and complete and type
|
// combine deleted and complete and type
|
||||||
expected = new ArrayList<DistributionSet>();
|
expected = new ArrayList<>();
|
||||||
expected.addAll(ds100Group1);
|
expected.addAll(ds100Group1);
|
||||||
expected.addAll(ds100Group2);
|
expected.addAll(ds100Group2);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
||||||
@@ -570,7 +636,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(200)
|
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(200)
|
||||||
.containsOnly(expected.toArray(new DistributionSet[0]));
|
.containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
expected = new ArrayList<DistributionSet>();
|
expected = new ArrayList<>();
|
||||||
expected.add(dsDeleted);
|
expected.add(dsDeleted);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
||||||
@@ -583,7 +649,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement
|
||||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
|
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
|
||||||
|
|
||||||
expected = new ArrayList<DistributionSet>();
|
expected = new ArrayList<>();
|
||||||
expected.add(dsNewType);
|
expected.add(dsNewType);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement
|
||||||
@@ -591,7 +657,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.containsOnly(expected.toArray(new DistributionSet[0]));
|
.containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
// combine deleted and complete and type and text
|
// combine deleted and complete and type and text
|
||||||
expected = new ArrayList<DistributionSet>();
|
expected = new ArrayList<>();
|
||||||
expected.addAll(ds100Group2);
|
expected.addAll(ds100Group2);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setType(standardDsType).setSearchText("%test2");
|
.setType(standardDsType).setSearchText("%test2");
|
||||||
@@ -615,7 +681,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
|
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
|
||||||
|
|
||||||
// combine deleted and complete and type and text and tag
|
// combine deleted and complete and type and text and tag
|
||||||
expected = new ArrayList<DistributionSet>();
|
expected = new ArrayList<>();
|
||||||
expected.addAll(ds100Group2);
|
expected.addAll(ds100Group2);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
||||||
.setSearchText("%test2").setTagNames(Lists.newArrayList(dsTagA.getName()));
|
.setSearchText("%test2").setTagNames(Lists.newArrayList(dsTagA.getName()));
|
||||||
@@ -637,7 +703,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
private List<Target> sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable<Target> targs,
|
private List<Target> sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable<Target> targs,
|
||||||
final Status status, final String... msgs) {
|
final Status status, final String... msgs) {
|
||||||
final List<Target> result = new ArrayList<Target>();
|
final List<Target> result = new ArrayList<>();
|
||||||
for (final Target t : targs) {
|
for (final Target t : targs) {
|
||||||
final List<Action> findByTarget = actionRepository.findByTarget(t);
|
final List<Action> findByTarget = actionRepository.findByTarget(t);
|
||||||
for (final Action action : findByTarget) {
|
for (final Action action : findByTarget) {
|
||||||
@@ -730,7 +796,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
dsAssigned.getVersion());
|
dsAssigned.getVersion());
|
||||||
final Target target = new Target("4712");
|
final Target target = new Target("4712");
|
||||||
final Target savedTarget = targetManagement.createTarget(target);
|
final Target savedTarget = targetManagement.createTarget(target);
|
||||||
final List<Target> toAssign = new ArrayList<Target>();
|
final List<Target> toAssign = new ArrayList<>();
|
||||||
toAssign.add(savedTarget);
|
toAssign.add(savedTarget);
|
||||||
deploymentManagement.assignDistributionSet(dsAssigned, toAssign);
|
deploymentManagement.assignDistributionSet(dsAssigned, toAssign);
|
||||||
|
|
||||||
@@ -744,38 +810,6 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
|
|||||||
.getTotalElements()).isEqualTo(2);
|
.getTotalElements()).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* helper method which re-orders a list as expected. Re-orders the given
|
|
||||||
* distribution set in the order as given and returns a new list with the
|
|
||||||
* new order.
|
|
||||||
*
|
|
||||||
* @param dsThree
|
|
||||||
* @param buildDistributionSets
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<DistributionSet> reOrderDSList(final Iterable<DistributionSet> buildDistributionSets,
|
|
||||||
final DistributionSet... ds) {
|
|
||||||
final List<DistributionSet> reOrderedList = new ArrayList<>();
|
|
||||||
|
|
||||||
final Iterator<DistributionSet> iterator = buildDistributionSets.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
final DistributionSet next = iterator.next();
|
|
||||||
int reorder = -1;
|
|
||||||
for (int index = 0; index < ds.length; index++) {
|
|
||||||
if (next.equals(ds[index])) {
|
|
||||||
reorder = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (reorder >= 0) {
|
|
||||||
reOrderedList.add(reorder, next);
|
|
||||||
} else {
|
|
||||||
reOrderedList.add(next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return reOrderedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Target sendUpdateActionStatusToTarget(final Status status, final Action updActA, final Target t,
|
private Target sendUpdateActionStatusToTarget(final Status status, final Action updActA, final Target t,
|
||||||
final String... msgs) {
|
final String... msgs) {
|
||||||
updActA.setStatus(status);
|
updActA.setStatus(status);
|
||||||
@@ -10,11 +10,11 @@ package org.eclipse.hawkbit.repository;
|
|||||||
|
|
||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,14 +24,18 @@ import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
|
|||||||
import org.eclipse.hawkbit.RandomGeneratedInputStream;
|
import org.eclipse.hawkbit.RandomGeneratedInputStream;
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||||
|
import org.eclipse.hawkbit.repository.model.CustomSoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -51,6 +55,165 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
@Stories("Software Management")
|
@Stories("Software Management")
|
||||||
public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
|
public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Try to update non updatable fields results in repository doing nothing.")
|
||||||
|
public void updateTypeNonUpdateableFieldsFails() {
|
||||||
|
final SoftwareModuleType created = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("test-key", "test-name", "test-desc", 1));
|
||||||
|
|
||||||
|
created.setName("a new name");
|
||||||
|
final SoftwareModuleType updated = softwareManagement.updateSoftwareModuleType(created);
|
||||||
|
|
||||||
|
assertThat(updated.getOptLockRevision())
|
||||||
|
.as("Expected version number of updated entitity to be equal to created version")
|
||||||
|
.isEqualTo(created.getOptLockRevision());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.")
|
||||||
|
public void updateNothingResultsInUnchangedRepositoryForType() {
|
||||||
|
final SoftwareModuleType created = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("test-key", "test-name", "test-desc", 1));
|
||||||
|
|
||||||
|
final SoftwareModuleType updated = softwareManagement.updateSoftwareModuleType(created);
|
||||||
|
|
||||||
|
assertThat(updated.getOptLockRevision())
|
||||||
|
.as("Expected version number of updated entitity to be equal to created version")
|
||||||
|
.isEqualTo(created.getOptLockRevision());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Calling update for changed fields results in change in the repository.")
|
||||||
|
public void updateSoftareModuleTypeFieldsToNewValue() {
|
||||||
|
final SoftwareModuleType created = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("test-key", "test-name", "test-desc", 1));
|
||||||
|
|
||||||
|
created.setDescription("changed");
|
||||||
|
created.setColour("changed");
|
||||||
|
|
||||||
|
final SoftwareModuleType updated = softwareManagement.updateSoftwareModuleType(created);
|
||||||
|
|
||||||
|
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entitity is")
|
||||||
|
.isEqualTo(created.getOptLockRevision() + 1);
|
||||||
|
assertThat(updated.getDescription()).as("Updated description is").isEqualTo("changed");
|
||||||
|
assertThat(updated.getColour()).as("Updated vendor is").isEqualTo("changed");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Try to update non updatable fields results in repository doing nothing.")
|
||||||
|
public void updateNonUpdateableFieldsFails() {
|
||||||
|
final SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||||
|
|
||||||
|
ah.setName("a new name");
|
||||||
|
final SoftwareModule updated = softwareManagement.updateSoftwareModule(ah);
|
||||||
|
|
||||||
|
assertThat(updated.getOptLockRevision())
|
||||||
|
.as("Expected version number of updated entitity to be equal to created version")
|
||||||
|
.isEqualTo(ah.getOptLockRevision());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.")
|
||||||
|
public void updateNothingResultsInUnchangedRepository() {
|
||||||
|
final SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||||
|
|
||||||
|
final SoftwareModule updated = softwareManagement.updateSoftwareModule(ah);
|
||||||
|
|
||||||
|
assertThat(updated.getOptLockRevision())
|
||||||
|
.as("Expected version number of updated entitity to be equal to created version")
|
||||||
|
.isEqualTo(ah.getOptLockRevision());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Calling update for changed fields results in change in the repository.")
|
||||||
|
public void updateSoftareModuleFieldsToNewValue() {
|
||||||
|
final SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", "test desc", "test vendor"));
|
||||||
|
|
||||||
|
ah.setDescription("changed");
|
||||||
|
ah.setVendor("changed");
|
||||||
|
final SoftwareModule updated = softwareManagement.updateSoftwareModule(ah);
|
||||||
|
|
||||||
|
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entitity is")
|
||||||
|
.isEqualTo(ah.getOptLockRevision() + 1);
|
||||||
|
assertThat(updated.getDescription()).as("Updated description is").isEqualTo("changed");
|
||||||
|
assertThat(updated.getVendor()).as("Updated vendor is").isEqualTo("changed");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Create Software Module call fails when called for existing entity.")
|
||||||
|
public void createModuleCallFailsForExistingModule() {
|
||||||
|
final SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", "test desc", "test vendor"));
|
||||||
|
try {
|
||||||
|
softwareManagement.createSoftwareModule(ah);
|
||||||
|
fail("Should not have worked as module already exists.");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Create Software Modules call fails when called for existing entities.")
|
||||||
|
public void createModulesCallFailsForExistingModule() {
|
||||||
|
final List<SoftwareModule> modules = softwareManagement.createSoftwareModule(
|
||||||
|
Lists.newArrayList(new SoftwareModule(appType, "agent-hub", "1.0.1", "test desc", "test vendor"),
|
||||||
|
new SoftwareModule(appType, "agent-hub", "1.0.2", "test desc", "test vendor")));
|
||||||
|
try {
|
||||||
|
softwareManagement.createSoftwareModule(modules);
|
||||||
|
fail("Should not have worked as module already exists.");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Create Software Module Type call fails when called for existing entity.")
|
||||||
|
public void createModuleTypeCallFailsForExistingType() {
|
||||||
|
final SoftwareModuleType created = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("test-key", "test-name", "test-desc", 1));
|
||||||
|
|
||||||
|
try {
|
||||||
|
softwareManagement.createSoftwareModuleType(created);
|
||||||
|
fail("Should not have worked as module already exists.");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Create Software Module Types call fails when called for existing entities.")
|
||||||
|
public void createModuleTypesCallFailsForExistingTypes() {
|
||||||
|
final List<SoftwareModuleType> created = softwareManagement.createSoftwareModuleType(
|
||||||
|
Lists.newArrayList(new SoftwareModuleType("test-key-bumlux", "test-name", "test-desc", 1),
|
||||||
|
new SoftwareModuleType("test-key-bumlux2", "test-name2", "test-desc", 1)));
|
||||||
|
|
||||||
|
try {
|
||||||
|
softwareManagement.createSoftwareModuleType(created);
|
||||||
|
fail("Should not have worked as module already exists.");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Calling update for changing fields to null results in change in the repository.")
|
||||||
|
public void eraseSoftareModuleFields() {
|
||||||
|
final SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", "test desc", "test vendor"));
|
||||||
|
|
||||||
|
ah.setDescription(null);
|
||||||
|
ah.setVendor(null);
|
||||||
|
final SoftwareModule updated = softwareManagement.updateSoftwareModule(ah);
|
||||||
|
|
||||||
|
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entitity is")
|
||||||
|
.isEqualTo(ah.getOptLockRevision() + 1);
|
||||||
|
assertThat(updated.getDescription()).as("Updated description is").isNull();
|
||||||
|
assertThat(updated.getVendor()).as("Updated vendor is").isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("searched for software modules based on the various filter options, e.g. name,desc,type, version.")
|
@Description("searched for software modules based on the various filter options, e.g. name,desc,type, version.")
|
||||||
public void findSoftwareModuleByFilters() {
|
public void findSoftwareModuleByFilters() {
|
||||||
@@ -105,7 +268,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Searches for software modules based on a list of IDs.")
|
@Description("Searches for software modules based on a list of IDs.")
|
||||||
public void findSoftwareModulesByIdAndType() {
|
public void findSoftwareModulesById() {
|
||||||
|
|
||||||
final List<Long> modules = new ArrayList<Long>();
|
final List<Long> modules = new ArrayList<Long>();
|
||||||
|
|
||||||
@@ -118,6 +281,54 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
assertThat(softwareManagement.findSoftwareModulesById(modules)).hasSize(2);
|
assertThat(softwareManagement.findSoftwareModulesById(modules)).hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Searches for software modules by type.")
|
||||||
|
public void findSoftwareModulesByType() {
|
||||||
|
// found in test
|
||||||
|
final SoftwareModule one = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(osType, "one", "one", null, ""));
|
||||||
|
final SoftwareModule two = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(osType, "two", "two", null, ""));
|
||||||
|
// ignored
|
||||||
|
softwareManagement.deleteSoftwareModule(
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "deleted", "deleted", null, "")));
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(appType, "three", "3.0.2", null, ""));
|
||||||
|
|
||||||
|
assertThat(softwareManagement.findSoftwareModulesByType(pageReq, osType).getContent())
|
||||||
|
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
|
||||||
|
.contains(two, one);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Counts all software modules in the repsitory that are not marked as deleted.")
|
||||||
|
public void countSoftwareModulesAll() {
|
||||||
|
// found in test
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "one", "one", null, ""));
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(appType, "two", "two", null, ""));
|
||||||
|
// ignored
|
||||||
|
softwareManagement.deleteSoftwareModule(
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "deleted", "deleted", null, "")));
|
||||||
|
|
||||||
|
assertThat(softwareManagement.countSoftwareModulesAll()).as("Expected to find the following number of modules:")
|
||||||
|
.isEqualTo(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Counts for software modules by type.")
|
||||||
|
public void countSoftwareModulesByType() {
|
||||||
|
// found in test
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "one", "one", null, ""));
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "two", "two", null, ""));
|
||||||
|
|
||||||
|
// ignored
|
||||||
|
softwareManagement.deleteSoftwareModule(
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "deleted", "deleted", null, "")));
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(appType, "three", "3.0.2", null, ""));
|
||||||
|
|
||||||
|
assertThat(softwareManagement.countSoftwareModulesByType(osType))
|
||||||
|
.as("Expected to find the following number of modules:").isEqualTo(2);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).")
|
@Description("Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).")
|
||||||
public void deleteAssignedAndUnassignedSoftwareModuleTypes() {
|
public void deleteAssignedAndUnassignedSoftwareModuleTypes() {
|
||||||
@@ -419,32 +630,194 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
*
|
@Description("Test verfies that results are returned based on given filter parameters and in the specified order.")
|
||||||
* @param findAll
|
public void findSoftwareModuleOrderByDistributionModuleNameAscModuleVersionAsc() {
|
||||||
* @return
|
// test meta data
|
||||||
*/
|
final SoftwareModuleType testType = softwareManagement
|
||||||
@SuppressWarnings("rawtypes")
|
.createSoftwareModuleType(new SoftwareModuleType("thetype", "thename", "desc", 100));
|
||||||
private Collection iterable2Collection(final Iterable iterable) {
|
final DistributionSetType testDsType = distributionSetManagement
|
||||||
final Collection<Object> col = new ArrayList<Object>();
|
.createDistributionSetType(new DistributionSetType("key", "name", "desc").addMandatoryModuleType(osType)
|
||||||
for (final Object o : iterable) {
|
.addOptionalModuleType(testType));
|
||||||
col.add(o);
|
|
||||||
}
|
// found in test
|
||||||
return col;
|
final SoftwareModule unassigned = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "asis", "found", null, ""));
|
||||||
|
final SoftwareModule one = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "found", "b", null, ""));
|
||||||
|
final SoftwareModule two = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "found", "c", null, ""));
|
||||||
|
final SoftwareModule differentName = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "differentname", "d", null, ""));
|
||||||
|
|
||||||
|
// ignored
|
||||||
|
final SoftwareModule deleted = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "deleted", "deleted", null, ""));
|
||||||
|
final SoftwareModule four = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(osType, "sdfjhsdj", "e", null, ""));
|
||||||
|
|
||||||
|
final DistributionSet set = distributionSetManagement.createDistributionSet(new DistributionSet("set", "1",
|
||||||
|
"desc", testDsType, Lists.newArrayList(one, two, deleted, four, differentName)));
|
||||||
|
softwareManagement.deleteSoftwareModule(deleted);
|
||||||
|
|
||||||
|
// with filter on name, version and module type
|
||||||
|
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(pageReq,
|
||||||
|
set.getId(), "found", testType).getContent())
|
||||||
|
.as("Found modules with given name, given module type and the assigned ones first")
|
||||||
|
.containsExactly(new CustomSoftwareModule(one, true), new CustomSoftwareModule(two, true),
|
||||||
|
new CustomSoftwareModule(unassigned, false));
|
||||||
|
|
||||||
|
// with filter on module type only
|
||||||
|
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(pageReq,
|
||||||
|
set.getId(), null, testType).getContent())
|
||||||
|
.as("Found modules with given module type and the assigned ones first").containsExactly(
|
||||||
|
new CustomSoftwareModule(differentName, true), new CustomSoftwareModule(one, true),
|
||||||
|
new CustomSoftwareModule(two, true), new CustomSoftwareModule(unassigned, false));
|
||||||
|
|
||||||
|
// without any filter
|
||||||
|
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(pageReq,
|
||||||
|
set.getId(), null, null).getContent()).as("Found modules with the assigned ones first").containsExactly(
|
||||||
|
new CustomSoftwareModule(differentName, true), new CustomSoftwareModule(one, true),
|
||||||
|
new CustomSoftwareModule(two, true), new CustomSoftwareModule(four, true),
|
||||||
|
new CustomSoftwareModule(unassigned, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
*
|
@Description("Checks that number of modules is returned as expected based on given filters.")
|
||||||
*/
|
public void countSoftwareModuleByFilters() {
|
||||||
private void printDSTags() {
|
|
||||||
System.out.println("==============================================================================");
|
// test meta data
|
||||||
for (final DistributionSet d : distributionSetRepository.findAll()) {
|
final SoftwareModuleType testType = softwareManagement
|
||||||
System.out.printf("%s\t[", d.getName());
|
.createSoftwareModuleType(new SoftwareModuleType("thetype", "thename", "desc", 100));
|
||||||
for (final DistributionSetTag t : d.getTags()) {
|
final DistributionSetType testDsType = distributionSetManagement
|
||||||
System.out.printf("%s ", t.getName());
|
.createDistributionSetType(new DistributionSetType("key", "name", "desc").addMandatoryModuleType(osType)
|
||||||
}
|
.addOptionalModuleType(testType));
|
||||||
System.out.println("]");
|
|
||||||
|
// test modules
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(testType, "asis", "found", null, ""));
|
||||||
|
final SoftwareModule one = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "found", "b", null, ""));
|
||||||
|
final SoftwareModule two = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "found", "c", null, ""));
|
||||||
|
final SoftwareModule differentName = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "differentname", "d", null, ""));
|
||||||
|
final SoftwareModule four = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(osType, "found", "3.0.2", null, ""));
|
||||||
|
|
||||||
|
// one soft deleted
|
||||||
|
final SoftwareModule deleted = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "deleted", "deleted", null, ""));
|
||||||
|
distributionSetManagement.createDistributionSet(new DistributionSet("set", "1", "desc", testDsType,
|
||||||
|
Lists.newArrayList(one, two, deleted, four, differentName)));
|
||||||
|
softwareManagement.deleteSoftwareModule(deleted);
|
||||||
|
|
||||||
|
// test
|
||||||
|
assertThat(softwareManagement.countSoftwareModuleByFilters("found", testType))
|
||||||
|
.as("Number of modules with given name or version and type").isEqualTo(3);
|
||||||
|
assertThat(softwareManagement.countSoftwareModuleByFilters(null, testType))
|
||||||
|
.as("Number of modules with given type").isEqualTo(4);
|
||||||
|
assertThat(softwareManagement.countSoftwareModuleByFilters(null, null)).as("Number of modules overall")
|
||||||
|
.isEqualTo(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that all undeleted software modules are found in the repository.")
|
||||||
|
public void countSoftwareModuleTypesAll() {
|
||||||
|
final SoftwareModuleType testType = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("thetype", "thename", "desc", 100));
|
||||||
|
final DistributionSetType testDsType = distributionSetManagement
|
||||||
|
.createDistributionSetType(new DistributionSetType("key", "name", "desc").addMandatoryModuleType(osType)
|
||||||
|
.addOptionalModuleType(testType));
|
||||||
|
final SoftwareModule four = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(osType, "found", "3.0.2", null, ""));
|
||||||
|
|
||||||
|
// one soft deleted
|
||||||
|
final SoftwareModule deleted = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "deleted", "deleted", null, ""));
|
||||||
|
distributionSetManagement.createDistributionSet(
|
||||||
|
new DistributionSet("set", "1", "desc", testDsType, Lists.newArrayList(deleted, four)));
|
||||||
|
softwareManagement.deleteSoftwareModule(deleted);
|
||||||
|
|
||||||
|
assertThat(softwareManagement.countSoftwareModulesAll()).as("Number of undeleted modules").isEqualTo(1);
|
||||||
|
assertThat(softwareModuleRepository.count()).as("Number of all modules").isEqualTo(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Checks that software module typeis found based on given name.")
|
||||||
|
public void findSoftwareModuleTypeByName() {
|
||||||
|
final SoftwareModuleType found = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("thetype", "thename", "desc", 100));
|
||||||
|
softwareManagement.createSoftwareModuleType(new SoftwareModuleType("thetype2", "anothername", "desc", 100));
|
||||||
|
|
||||||
|
assertThat(softwareManagement.findSoftwareModuleTypeByName("thename")).as("Type with given name")
|
||||||
|
.isEqualTo(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that it is not possible to create a type that alrady exists.")
|
||||||
|
public void createSoftwareModuleTypeFailsWithExistingEntity() {
|
||||||
|
final SoftwareModuleType created = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("thetype", "thename", "desc", 100));
|
||||||
|
try {
|
||||||
|
softwareManagement.createSoftwareModuleType(created);
|
||||||
|
fail("should not have worked as module type already exists");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that it is not possible to create a list of types where one already exists.")
|
||||||
|
public void createSoftwareModuleTypesFailsWithExistingEntity() {
|
||||||
|
final SoftwareModuleType created = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("thetype", "thename", "desc", 100));
|
||||||
|
try {
|
||||||
|
softwareManagement.createSoftwareModuleType(
|
||||||
|
Lists.newArrayList(created, new SoftwareModuleType("anothertype", "anothername", "desc", 100)));
|
||||||
|
fail("should not have worked as module type already exists");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that multiple types are created as requested.")
|
||||||
|
public void createMultipleoftwareModuleTypes() {
|
||||||
|
final List<SoftwareModuleType> created = softwareManagement
|
||||||
|
.createSoftwareModuleType(Lists.newArrayList(new SoftwareModuleType("thetype", "thename", "desc", 100),
|
||||||
|
new SoftwareModuleType("thetype2", "thename2", "desc2", 100)));
|
||||||
|
|
||||||
|
assertThat(created.size()).as("Number of created types").isEqualTo(2);
|
||||||
|
assertThat(softwareManagement.countSoftwareModuleTypesAll()).as("Number of types in repository").isEqualTo(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that sofwtare modules are resturned that are assigned to given DS.")
|
||||||
|
public void findSoftwareModuleByAssignedTo() {
|
||||||
|
// test meta data
|
||||||
|
final SoftwareModuleType testType = softwareManagement
|
||||||
|
.createSoftwareModuleType(new SoftwareModuleType("thetype", "thename", "desc", 100));
|
||||||
|
final DistributionSetType testDsType = distributionSetManagement
|
||||||
|
.createDistributionSetType(new DistributionSetType("key", "name", "desc").addMandatoryModuleType(osType)
|
||||||
|
.addOptionalModuleType(testType));
|
||||||
|
|
||||||
|
// test modules
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(testType, "asis", "found", null, ""));
|
||||||
|
final SoftwareModule one = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "found", "b", null, ""));
|
||||||
|
final SoftwareModule two = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "found", "c", null, ""));
|
||||||
|
|
||||||
|
// one soft deleted
|
||||||
|
final SoftwareModule deleted = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(testType, "deleted", "deleted", null, ""));
|
||||||
|
final DistributionSet set = distributionSetManagement.createDistributionSet(
|
||||||
|
new DistributionSet("set", "1", "desc", testDsType, Lists.newArrayList(one, deleted)));
|
||||||
|
softwareManagement.deleteSoftwareModule(deleted);
|
||||||
|
|
||||||
|
assertThat(softwareManagement.findSoftwareModuleByAssignedTo(pageReq, set).getContent())
|
||||||
|
.as("Found this number of modules").hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -479,6 +852,27 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
assertThat(softwareModuleMetadata.get(0).getSoftwareModule().getId()).isEqualTo(ah.getId());
|
assertThat(softwareModuleMetadata.get(0).getSoftwareModule().getId()).isEqualTo(ah.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Checks that metadata for a software module cannot be created for an existing key.")
|
||||||
|
public void createSoftwareModuleMetadataFailsIfKeyExists() {
|
||||||
|
|
||||||
|
final String knownKey1 = "myKnownKey1";
|
||||||
|
final String knownValue1 = "myKnownValue1";
|
||||||
|
final String knownValue2 = "myKnownValue2";
|
||||||
|
|
||||||
|
final SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||||
|
|
||||||
|
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey1, ah, knownValue1));
|
||||||
|
|
||||||
|
try {
|
||||||
|
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey1, ah, knownValue2));
|
||||||
|
fail("should not have worked as module metadata already exists");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithUser(allSpPermissions = true)
|
@WithUser(allSpPermissions = true)
|
||||||
@Description("Checks that metadata for a software module can be updated.")
|
@Description("Checks that metadata for a software module can be updated.")
|
||||||
@@ -525,6 +919,47 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
assertThat(updated.getSoftwareModule().getId()).isEqualTo(ah.getId());
|
assertThat(updated.getSoftwareModule().getId()).isEqualTo(ah.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that existing metadata can be deleted.")
|
||||||
|
public void deleteSoftwareModuleMetadata() {
|
||||||
|
final String knownKey1 = "myKnownKey1";
|
||||||
|
final String knownValue1 = "myKnownValue1";
|
||||||
|
|
||||||
|
SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||||
|
|
||||||
|
ah = softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey1, ah, knownValue1))
|
||||||
|
.getSoftwareModule();
|
||||||
|
|
||||||
|
assertThat(softwareManagement.findSoftwareModuleById(ah.getId()).getMetadata())
|
||||||
|
.as("Contains the created metadata element")
|
||||||
|
.containsExactly(new SoftwareModuleMetadata(knownKey1, ah, knownValue1));
|
||||||
|
|
||||||
|
softwareManagement.deleteSoftwareModuleMetadata(new SwMetadataCompositeKey(ah, knownKey1));
|
||||||
|
assertThat(softwareManagement.findSoftwareModuleById(ah.getId()).getMetadata()).as("Metadata elemenets are")
|
||||||
|
.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that non existing metadata find results in exception.")
|
||||||
|
public void findSoftwareModuleMetadataFailsIfEntryDoesNotExist() {
|
||||||
|
final String knownKey1 = "myKnownKey1";
|
||||||
|
final String knownValue1 = "myKnownValue1";
|
||||||
|
|
||||||
|
SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||||
|
|
||||||
|
ah = softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey1, ah, knownValue1))
|
||||||
|
.getSoftwareModule();
|
||||||
|
|
||||||
|
try {
|
||||||
|
softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(ah, "doesnotexist"));
|
||||||
|
fail("should not have worked as module metadata with that key does not exist");
|
||||||
|
} catch (final EntityNotFoundException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Queries and loads the metadata related to a given software module.")
|
@Description("Queries and loads the metadata related to a given software module.")
|
||||||
public void findAllSoftwareModuleMetadataBySwId() {
|
public void findAllSoftwareModuleMetadataBySwId() {
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ import static org.fest.assertions.api.Assertions.assertThat;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
@@ -20,9 +23,11 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilte
|
|||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.Tag;
|
import org.eclipse.hawkbit.repository.model.Tag;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -158,6 +163,98 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
|||||||
return new DistributionSetFilterBuilder();
|
return new DistributionSetFilterBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verifies the toogle mechanism by means on assigning tag if at least on DS in the list does not have"
|
||||||
|
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||||
|
public void assignAndUnassignDistributionSetTags() {
|
||||||
|
final List<DistributionSet> groupA = TestDataUtil.generateDistributionSets(20, softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
final List<DistributionSet> groupB = TestDataUtil.generateDistributionSets("unassigned", 20, softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
|
||||||
|
final DistributionSetTag tag = tagManagement
|
||||||
|
.createDistributionSetTag(new DistributionSetTag("tag1", "tagdesc1", ""));
|
||||||
|
|
||||||
|
// toggle A only -> A is now assigned
|
||||||
|
DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(groupA, tag);
|
||||||
|
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getAssigned()).isEqualTo(20);
|
||||||
|
assertThat(result.getAssignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
|
||||||
|
groupA.stream().map(set -> set.getId()).collect(Collectors.toList())));
|
||||||
|
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getUnassignedDs()).isEmpty();
|
||||||
|
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||||
|
|
||||||
|
// toggle A+B -> A is still assigned and B is assigned as well
|
||||||
|
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||||
|
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||||
|
assertThat(result.getAssigned()).isEqualTo(20);
|
||||||
|
assertThat(result.getAssignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
|
||||||
|
groupB.stream().map(set -> set.getId()).collect(Collectors.toList())));
|
||||||
|
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getUnassignedDs()).isEmpty();
|
||||||
|
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||||
|
|
||||||
|
// toggle A+B -> both unassigned
|
||||||
|
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||||
|
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getAssigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getAssignedDs()).isEmpty();
|
||||||
|
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||||
|
assertThat(result.getUnassignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
|
||||||
|
concat(groupB, groupA).stream().map(set -> set.getId()).collect(Collectors.toList())));
|
||||||
|
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verifies the toogle mechanism by means on assigning tag if at least on target in the list does not have"
|
||||||
|
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||||
|
public void assignAndUnassignTargetTags() {
|
||||||
|
final List<Target> groupA = targetManagement.createTargets(TestDataUtil.generateTargets(20, ""));
|
||||||
|
final List<Target> groupB = targetManagement.createTargets(TestDataUtil.generateTargets(20, "groupb"));
|
||||||
|
|
||||||
|
final TargetTag tag = tagManagement.createTargetTag(new TargetTag("tag1", "tagdesc1", ""));
|
||||||
|
|
||||||
|
// toggle A only -> A is now assigned
|
||||||
|
TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(groupA, tag);
|
||||||
|
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getAssigned()).isEqualTo(20);
|
||||||
|
assertThat(result.getAssignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
|
||||||
|
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||||
|
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getUnassignedTargets()).isEmpty();
|
||||||
|
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||||
|
|
||||||
|
// toggle A+B -> A is still assigned and B is assigned as well
|
||||||
|
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||||
|
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||||
|
assertThat(result.getAssigned()).isEqualTo(20);
|
||||||
|
assertThat(result.getAssignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
|
||||||
|
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||||
|
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getUnassignedTargets()).isEmpty();
|
||||||
|
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||||
|
|
||||||
|
// toggle A+B -> both unassigned
|
||||||
|
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||||
|
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getAssigned()).isEqualTo(0);
|
||||||
|
assertThat(result.getAssignedTargets()).isEmpty();
|
||||||
|
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||||
|
assertThat(result.getUnassignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
|
||||||
|
concat(groupB, groupA).stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||||
|
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
private final <T> List<T> concat(final List<T>... targets) {
|
||||||
|
final List<T> result = new ArrayList<>();
|
||||||
|
Arrays.asList(targets).forEach(result::addAll);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Ensures that all tags are retrieved through repository.")
|
@Description("Ensures that all tags are retrieved through repository.")
|
||||||
public void findAllTargetTags() {
|
public void findAllTargetTags() {
|
||||||
@@ -266,47 +363,58 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||||
public void failedDuplicateTargetTagNameException() {
|
public void failedDuplicateTargetTagNameException() {
|
||||||
tagManagement.createTargetTag(new TargetTag("A"));
|
tagManagement.createTargetTag(new TargetTag("A"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tagManagement.createTargetTag(new TargetTag("A"));
|
tagManagement.createTargetTag(new TargetTag("A"));
|
||||||
fail("Expected EntityAlreadyExistsException");
|
fail("should not have worked as tag already exists");
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||||
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
||||||
tagManagement.createTargetTag(new TargetTag("A"));
|
tagManagement.createTargetTag(new TargetTag("A"));
|
||||||
final TargetTag tag = tagManagement.createTargetTag(new TargetTag("B"));
|
final TargetTag tag = tagManagement.createTargetTag(new TargetTag("B"));
|
||||||
tag.setName("A");
|
tag.setName("A");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tagManagement.updateTargetTag(tag);
|
tagManagement.updateTargetTag(tag);
|
||||||
fail("Expected EntityAlreadyExistsException");
|
fail("should not have worked as tag already exists");
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||||
public void failedDuplicateDsTagNameException() {
|
public void failedDuplicateDsTagNameException() {
|
||||||
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
||||||
try {
|
try {
|
||||||
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
||||||
fail("Expected EntityAlreadyExistsException");
|
fail("should not have worked as tag already exists");
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||||
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
||||||
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
||||||
final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("B"));
|
final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("B"));
|
||||||
tag.setName("A");
|
tag.setName("A");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tagManagement.updateDistributionSetTag(tag);
|
tagManagement.updateDistributionSetTag(tag);
|
||||||
fail("Expected EntityAlreadyExistsException");
|
fail("should not have worked as tag already exists");
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
@@ -22,10 +23,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
/**
|
/**
|
||||||
* Test class for {@link TargetFilterQueryManagement}.
|
* Test class for {@link TargetFilterQueryManagement}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Features("Component Tests - Repository")
|
@Features("Component Tests - Repository")
|
||||||
@Stories("Target Filter Query Management")
|
@Stories("Target Filter Query Management")
|
||||||
public class TargetFilterQueryManagenmentTest extends AbstractIntegrationTest {
|
public class TargetFilterQueryManagenmentTest extends AbstractIntegrationTest {
|
||||||
@@ -40,15 +38,20 @@ public class TargetFilterQueryManagenmentTest extends AbstractIntegrationTest {
|
|||||||
targetFilterQueryManagement.findTargetFilterQueryByName(filterName));
|
targetFilterQueryManagement.findTargetFilterQueryByName(filterName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = EntityAlreadyExistsException.class)
|
@Test
|
||||||
@Description("Checks if the EntityAlreadyExistsException is thrown if a targetfilterquery with the same name are created more than once.")
|
@Description("Checks if the EntityAlreadyExistsException is thrown if a targetfilterquery with the same name are created more than once.")
|
||||||
public void createDuplicateTargetFilterQuery() {
|
public void createDuplicateTargetFilterQuery() {
|
||||||
final String filterName = "new target filter duplicate";
|
final String filterName = "new target filter duplicate";
|
||||||
targetFilterQueryManagement
|
targetFilterQueryManagement
|
||||||
.createTargetFilterQuery(new TargetFilterQuery(filterName, "name==PendingTargets001"));
|
.createTargetFilterQuery(new TargetFilterQuery(filterName, "name==PendingTargets001"));
|
||||||
|
|
||||||
targetFilterQueryManagement
|
try {
|
||||||
.createTargetFilterQuery(new TargetFilterQuery(filterName, "name==PendingTargets001"));
|
targetFilterQueryManagement
|
||||||
|
.createTargetFilterQuery(new TargetFilterQuery(filterName, "name==PendingTargets001"));
|
||||||
|
fail("should not have worked as query already exists");
|
||||||
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -11,28 +11,34 @@ package org.eclipse.hawkbit.repository;
|
|||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||||
|
import org.eclipse.hawkbit.repository.specifications.TargetSpecifications;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Step;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
@Features("Component Tests - Repository")
|
@Features("Component Tests - Repository")
|
||||||
@@ -40,152 +46,626 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
public class TargetManagementSearchTest extends AbstractIntegrationTest {
|
public class TargetManagementSearchTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests different parameter combinations for target search operations. That includes both the test itself as a count operation with the same filters.")
|
@Description("Tests different parameter combinations for target search operations. "
|
||||||
|
+ "That includes both the test itself, as a count operation with the same filters "
|
||||||
|
+ "and query definitions by RSQL (named and un-named).")
|
||||||
public void targetSearchWithVariousFilterCombinations() {
|
public void targetSearchWithVariousFilterCombinations() {
|
||||||
final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("TargTag-A"));
|
final TargetTag targTagX = tagManagement.createTargetTag(new TargetTag("TargTag-X"));
|
||||||
final TargetTag targTagB = tagManagement.createTargetTag(new TargetTag("TargTag-B"));
|
final TargetTag targTagY = tagManagement.createTargetTag(new TargetTag("TargTag-Y"));
|
||||||
final TargetTag targTagC = tagManagement.createTargetTag(new TargetTag("TargTag-C"));
|
final TargetTag targTagZ = tagManagement.createTargetTag(new TargetTag("TargTag-Z"));
|
||||||
final TargetTag targTagD = tagManagement.createTargetTag(new TargetTag("TargTag-D"));
|
final TargetTag targTagW = tagManagement.createTargetTag(new TargetTag("TargTag-W"));
|
||||||
|
|
||||||
// TODO kaizimmerm: test also installedDS (not only assignedDS)
|
|
||||||
|
|
||||||
final DistributionSet setA = TestDataUtil.generateDistributionSet("", softwareManagement,
|
final DistributionSet setA = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
|
|
||||||
|
final DistributionSet installedSet = TestDataUtil.generateDistributionSet("another", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
|
||||||
final String targetDsAIdPref = "targ-A";
|
final String targetDsAIdPref = "targ-A";
|
||||||
List<Target> targAs = targetManagement.createTargets(
|
List<Target> targAs = targetManagement.createTargets(
|
||||||
TestDataUtil.buildTargetFixtures(100, targetDsAIdPref, targetDsAIdPref.concat(" description")));
|
TestDataUtil.buildTargetFixtures(100, targetDsAIdPref, targetDsAIdPref.concat(" description")));
|
||||||
targAs = targetManagement.toggleTagAssignment(targAs, targTagA).getAssignedTargets();
|
targAs = targetManagement.toggleTagAssignment(targAs, targTagX).getAssignedTargets();
|
||||||
|
|
||||||
final String targetDsBIdPref = "targ-B";
|
final String targetDsBIdPref = "targ-B";
|
||||||
List<Target> targBs = targetManagement.createTargets(
|
List<Target> targBs = targetManagement.createTargets(
|
||||||
TestDataUtil.buildTargetFixtures(100, targetDsBIdPref, targetDsBIdPref.concat(" description")));
|
TestDataUtil.buildTargetFixtures(100, targetDsBIdPref, targetDsBIdPref.concat(" description")));
|
||||||
targBs = targetManagement.toggleTagAssignment(targBs, targTagB).getAssignedTargets();
|
targBs = targetManagement.toggleTagAssignment(targBs, targTagY).getAssignedTargets();
|
||||||
targBs = targetManagement.toggleTagAssignment(targBs, targTagD).getAssignedTargets();
|
targBs = targetManagement.toggleTagAssignment(targBs, targTagW).getAssignedTargets();
|
||||||
|
|
||||||
final String targetDsCIdPref = "targ-C";
|
final String targetDsCIdPref = "targ-C";
|
||||||
List<Target> targCs = targetManagement.createTargets(
|
List<Target> targCs = targetManagement.createTargets(
|
||||||
TestDataUtil.buildTargetFixtures(100, targetDsCIdPref, targetDsCIdPref.concat(" description")));
|
TestDataUtil.buildTargetFixtures(100, targetDsCIdPref, targetDsCIdPref.concat(" description")));
|
||||||
targCs = targetManagement.toggleTagAssignment(targCs, targTagC).getAssignedTargets();
|
targCs = targetManagement.toggleTagAssignment(targCs, targTagZ).getAssignedTargets();
|
||||||
targCs = targetManagement.toggleTagAssignment(targCs, targTagD).getAssignedTargets();
|
targCs = targetManagement.toggleTagAssignment(targCs, targTagW).getAssignedTargets();
|
||||||
|
|
||||||
final String targetDsDIdPref = "targ-D";
|
final String targetDsDIdPref = "targ-D";
|
||||||
final Iterable<Target> targDs = targetManagement.createTargets(
|
final List<Target> targDs = targetManagement.createTargets(
|
||||||
TestDataUtil.buildTargetFixtures(100, targetDsDIdPref, targetDsDIdPref.concat(" description")));
|
TestDataUtil.buildTargetFixtures(100, targetDsDIdPref, targetDsDIdPref.concat(" description")));
|
||||||
|
|
||||||
deploymentManagement.assignDistributionSet(setA.getId(), targCs.iterator().next().getControllerId());
|
final String assignedC = targCs.iterator().next().getControllerId();
|
||||||
deploymentManagement.assignDistributionSet(setA.getId(), targAs.iterator().next().getControllerId());
|
deploymentManagement.assignDistributionSet(setA.getId(), assignedC);
|
||||||
deploymentManagement.assignDistributionSet(setA.getId(), targBs.iterator().next().getControllerId());
|
final String assignedA = targAs.iterator().next().getControllerId();
|
||||||
|
deploymentManagement.assignDistributionSet(setA.getId(), assignedA);
|
||||||
|
final String assignedB = targBs.iterator().next().getControllerId();
|
||||||
|
deploymentManagement.assignDistributionSet(setA.getId(), assignedB);
|
||||||
|
final String installedC = targCs.iterator().next().getControllerId();
|
||||||
|
final Long actionId = deploymentManagement.assignDistributionSet(installedSet.getId(), assignedC).getActions()
|
||||||
|
.get(0);
|
||||||
|
|
||||||
final List<TargetUpdateStatus> unknown = new ArrayList<TargetUpdateStatus>();
|
// set one installed DS also
|
||||||
|
final Action action = deploymentManagement.findActionWithDetails(actionId);
|
||||||
|
action.setStatus(Status.FINISHED);
|
||||||
|
controllerManagament.addUpdateActionStatus(
|
||||||
|
new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action);
|
||||||
|
deploymentManagement.assignDistributionSet(setA.getId(), installedC);
|
||||||
|
|
||||||
|
final List<TargetUpdateStatus> unknown = new ArrayList<>();
|
||||||
unknown.add(TargetUpdateStatus.UNKNOWN);
|
unknown.add(TargetUpdateStatus.UNKNOWN);
|
||||||
|
|
||||||
final List<TargetUpdateStatus> pending = new ArrayList<TargetUpdateStatus>();
|
final List<TargetUpdateStatus> pending = new ArrayList<>();
|
||||||
pending.add(TargetUpdateStatus.PENDING);
|
pending.add(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
final List<TargetUpdateStatus> both = new ArrayList<TargetUpdateStatus>();
|
final List<TargetUpdateStatus> both = new ArrayList<>();
|
||||||
both.add(TargetUpdateStatus.UNKNOWN);
|
both.add(TargetUpdateStatus.UNKNOWN);
|
||||||
both.add(TargetUpdateStatus.PENDING);
|
both.add(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
final PageRequest pageReq = new PageRequest(0, 500);
|
|
||||||
// try to find several targets with different filter settings
|
// try to find several targets with different filter settings
|
||||||
|
verifyThatRepositoryContains400Targets();
|
||||||
|
verifyThat200TargetsHaveTagD(targTagW, concat(targBs, targCs));
|
||||||
|
verifyThat100TargetsContainsGivenTextAndHaveTagAssigned(targTagY, targTagW, targBs);
|
||||||
|
verifyThat1TargetHasTagHasDescOrNameAndDs(targTagW, setA, targetManagement.findTargetByControllerID(assignedC));
|
||||||
|
verifyThat0TargetsWithTagAndDescOrNameHasDS(targTagW, setA);
|
||||||
|
verifyThat0TargetsWithNameOrdescAndDSHaveTag(targTagX, setA);
|
||||||
|
verifyThat3TargetsHaveDSAssigned(setA,
|
||||||
|
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
|
||||||
|
verifyThat1TargetWithDescOrNameHasDS(setA, targetManagement.findTargetByControllerID(assignedA));
|
||||||
|
List<Target> expected = concat(targAs, targBs, targCs, targDs);
|
||||||
|
expected.removeAll(
|
||||||
|
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
|
||||||
|
verifyThat397TargetsAreInStatusUnknown(unknown, expected);
|
||||||
|
expected = concat(targBs, targCs);
|
||||||
|
expected.removeAll(targetManagement.findTargetByControllerID(Lists.newArrayList(assignedB, assignedC)));
|
||||||
|
verifyThat198TargetsAreInStatusUnknownAndHaveGivenTags(targTagY, targTagW, unknown, expected);
|
||||||
|
verfyThat0TargetsAreInStatusUnknownAndHaveDSAssigned(setA, unknown);
|
||||||
|
expected = concat(targAs);
|
||||||
|
expected.remove(targetManagement.findTargetByControllerID(assignedA));
|
||||||
|
verifyThat99TargetsWithNameOrDescriptionAreInGivenStatus(unknown, expected);
|
||||||
|
expected = concat(targBs);
|
||||||
|
expected.remove(targetManagement.findTargetByControllerID(assignedB));
|
||||||
|
verifyThat99TargetsWithGivenNameOrDescAndTagAreInStatusUnknown(targTagW, unknown, expected);
|
||||||
|
verifyThat3TargetsAreInStatusPending(pending,
|
||||||
|
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
|
||||||
|
verifyThat3TargetsWithGivenDSAreInPending(setA, pending,
|
||||||
|
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
|
||||||
|
verifyThat1TargetWithGivenNameOrDescAndDSIsInPending(setA, pending,
|
||||||
|
targetManagement.findTargetByControllerID(assignedA));
|
||||||
|
verifyThat1TargetWithGivenNameOrDescAndTagAndDSIsInPending(targTagW, setA, pending,
|
||||||
|
targetManagement.findTargetByControllerID(assignedB));
|
||||||
|
verifyThat2TargetsWithGivenTagAndDSIsInPending(targTagW, setA, pending,
|
||||||
|
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedB, assignedC)));
|
||||||
|
verifyThat2TargetsWithGivenTagAreInPending(targTagW, pending,
|
||||||
|
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedB, assignedC)));
|
||||||
|
verifyThat200targetsWithGivenTagAreInStatusPendingorUnknown(targTagW, both, concat(targBs, targCs));
|
||||||
|
verfiyThat1TargetAIsInStatusPendingAndHasDSInstalled(installedSet, pending,
|
||||||
|
targetManagement.findTargetByControllerID(installedC));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO kaizimmerm: comment and check also the content itself, not only
|
@Step
|
||||||
// the numbers
|
private void verfiyThat1TargetAIsInStatusPendingAndHasDSInstalled(final DistributionSet installedSet,
|
||||||
// (containsOnly)
|
final List<TargetUpdateStatus> pending, final Target expected) {
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(400);
|
final TargetIdName expectedIdName = convertToIdName(expected);
|
||||||
|
final String query = "updatestatus==pending and installedds.name==" + installedSet.getName();
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, null, Boolean.FALSE, targTagD.getName())
|
assertThat(targetManagement
|
||||||
.getNumberOfElements()).isEqualTo(200).isEqualTo(Ints.saturatedCast(
|
.findTargetByFilters(pageReq, pending, null, installedSet.getId(), Boolean.FALSE, new String[0])
|
||||||
targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, targTagD.getName())));
|
.getContent()).as("has number of elements").hasSize(1)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null,
|
||||||
|
installedSet.getId(), Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsExactly(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
Slice<Target> x = targetManagement.findTargetByFilters(pageReq, null, "%targ-B%", null, Boolean.FALSE,
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, installedSet.getId(),
|
||||||
targTagB.getName(), targTagD.getName());
|
Boolean.FALSE, new String[0])).as("has number of elements").hasSize(1)
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(100).isEqualTo(Ints.saturatedCast(targetManagement
|
.as("and contains the following elements").containsExactly(expectedIdName)
|
||||||
.countTargetByFilters(null, "%targ-B%", null, Boolean.FALSE, targTagB.getName(), targTagD.getName())));
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findAllTargetIdsByTargetFilterQuery(pageReq, new TargetFilterQuery("test", query)));
|
||||||
x = targetManagement.findTargetByFilters(pageReq, null, "%targ-C%", setA.getId(), Boolean.FALSE,
|
|
||||||
targTagD.getName());
|
}
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(1).isEqualTo(Ints.saturatedCast(targetManagement
|
|
||||||
.countTargetByFilters(null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagD.getName())));
|
@Step
|
||||||
|
private void verifyThat200targetsWithGivenTagAreInStatusPendingorUnknown(final TargetTag targTagW,
|
||||||
x = targetManagement.findTargetByFilters(pageReq, null, "%targ-A%", setA.getId(), Boolean.FALSE,
|
final List<TargetUpdateStatus> both, final List<Target> expected) {
|
||||||
targTagD.getName());
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(0).isEqualTo(Ints.saturatedCast(targetManagement
|
|
||||||
.countTargetByFilters(null, "%targ-A%", setA.getId(), Boolean.FALSE, targTagD.getName())));
|
final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName();
|
||||||
|
|
||||||
x = targetManagement.findTargetByFilters(pageReq, null, "%targ-C%", setA.getId(), Boolean.FALSE,
|
assertThat(targetManagement.findTargetByFilters(pageReq, both, null, null, Boolean.FALSE, targTagW.getName())
|
||||||
targTagA.getName());
|
.getContent()).as("has number of elements").hasSize(200)
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(0).isEqualTo(Ints.saturatedCast(targetManagement
|
.as("that number is also returned by count query")
|
||||||
.countTargetByFilters(null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagA.getName())));
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(both, null, null,
|
||||||
|
Boolean.FALSE, targTagW.getName())))
|
||||||
x = targetManagement.findTargetByFilters(pageReq, null, null, setA.getId(), Boolean.FALSE, null);
|
.as("and contains the following elements").containsAll(expected)
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(3).isEqualTo(Ints
|
.as("and filter query returns the same result")
|
||||||
.saturatedCast(targetManagement.countTargetByFilters(null, null, setA.getId(), Boolean.FALSE, null)));
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
x = targetManagement.findTargetByFilters(pageReq, null, "%targ-A%", setA.getId(), Boolean.FALSE, null);
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(1).isEqualTo(Ints.saturatedCast(
|
|
||||||
targetManagement.countTargetByFilters(null, "%targ-A%", setA.getId(), Boolean.FALSE, null)));
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, both, null, null, Boolean.FALSE,
|
||||||
|
targTagW.getName())).as("has number of elements").hasSize(200).as("and contains the following elements")
|
||||||
x = targetManagement.findTargetByFilters(pageReq, unknown, null, null, Boolean.FALSE, null);
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(397).isEqualTo(
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null, Boolean.FALSE, null)));
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
x = targetManagement.findTargetByFilters(pageReq, unknown, null, null, Boolean.FALSE, targTagB.getName(),
|
|
||||||
targTagD.getName());
|
private static List<TargetIdName> convertToIdNames(final List<Target> expected) {
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(198).isEqualTo(Ints.saturatedCast(targetManagement
|
return expected.stream()
|
||||||
.countTargetByFilters(unknown, null, null, Boolean.FALSE, targTagB.getName(), targTagD.getName())));
|
.map(target -> new TargetIdName(target.getId(), target.getControllerId(), target.getName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
x = targetManagement.findTargetByFilters(pageReq, unknown, null, setA.getId(), Boolean.FALSE, null);
|
}
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(0).isEqualTo(Ints.saturatedCast(
|
|
||||||
targetManagement.countTargetByFilters(unknown, null, setA.getId(), Boolean.FALSE, null)));
|
private static TargetIdName convertToIdName(final Target target) {
|
||||||
|
return new TargetIdName(target.getId(), target.getControllerId(), target.getName());
|
||||||
x = targetManagement.findTargetByFilters(pageReq, unknown, "%targ-A%", null, Boolean.FALSE, null);
|
}
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(99).isEqualTo(Ints
|
|
||||||
.saturatedCast(targetManagement.countTargetByFilters(unknown, "%targ-A%", null, Boolean.FALSE, null)));
|
@Step
|
||||||
|
private void verifyThat2TargetsWithGivenTagAreInPending(final TargetTag targTagW,
|
||||||
x = targetManagement.findTargetByFilters(pageReq, unknown, "%targ-B%", null, Boolean.FALSE, targTagD.getName());
|
final List<TargetUpdateStatus> pending, final List<Target> expected) {
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(99).isEqualTo(Ints.saturatedCast(
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
targetManagement.countTargetByFilters(unknown, "%targ-B%", null, Boolean.FALSE, targTagD.getName())));
|
final String query = "updatestatus==pending and tag==" + targTagW.getName();
|
||||||
|
|
||||||
x = targetManagement.findTargetByFilters(pageReq, unknown, null, null, Boolean.FALSE, targTagD.getName());
|
assertThat(targetManagement.findTargetByFilters(pageReq, pending, null, null, Boolean.FALSE, targTagW.getName())
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(198).isEqualTo(Ints.saturatedCast(
|
.getContent()).as("has number of elements").hasSize(2)
|
||||||
targetManagement.countTargetByFilters(unknown, null, null, Boolean.FALSE, targTagD.getName())));
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
|
||||||
x = targetManagement.findTargetByFilters(pageReq, pending, null, null, Boolean.FALSE, null);
|
Boolean.FALSE, targTagW.getName())))
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(3).isEqualTo(
|
.as("and contains the following elements").containsAll(expected)
|
||||||
Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null, Boolean.FALSE, null)));
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
x = targetManagement.findTargetByFilters(pageReq, pending, null, setA.getId(), Boolean.FALSE, null);
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(3).isEqualTo(Ints.saturatedCast(
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
targetManagement.countTargetByFilters(pending, null, setA.getId(), Boolean.FALSE, null)));
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, Boolean.FALSE,
|
||||||
x = targetManagement.findTargetByFilters(pageReq, pending, "%targ-A%", setA.getId(), Boolean.FALSE, null);
|
targTagW.getName())).as("has number of elements").hasSize(2).as("and contains the following elements")
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(1).isEqualTo(Ints.saturatedCast(
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
targetManagement.countTargetByFilters(pending, "%targ-A%", setA.getId(), Boolean.FALSE, null)));
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
x = targetManagement.findTargetByFilters(pageReq, pending, "%targ-B%", setA.getId(), Boolean.FALSE,
|
}
|
||||||
targTagD.getName());
|
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(1).isEqualTo(Ints.saturatedCast(targetManagement
|
@Step
|
||||||
.countTargetByFilters(pending, "%targ-B%", setA.getId(), Boolean.FALSE, targTagD.getName())));
|
private void verifyThat2TargetsWithGivenTagAndDSIsInPending(final TargetTag targTagW, final DistributionSet setA,
|
||||||
|
final List<TargetUpdateStatus> pending, final List<Target> expected) {
|
||||||
x = targetManagement.findTargetByFilters(pageReq, pending, null, setA.getId(), Boolean.FALSE,
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
targTagD.getName());
|
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(2).isEqualTo(Ints.saturatedCast(
|
+ setA.getName() + ") and tag==" + targTagW.getName();
|
||||||
targetManagement.countTargetByFilters(pending, null, setA.getId(), Boolean.FALSE, targTagD.getName())));
|
|
||||||
|
assertThat(targetManagement
|
||||||
x = targetManagement.findTargetByFilters(pageReq, pending, null, null, Boolean.FALSE, targTagD.getName());
|
.findTargetByFilters(pageReq, pending, null, setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||||
assertThat(x.getNumberOfElements()).isEqualTo(2).isEqualTo(Ints.saturatedCast(
|
.getContent()).as("has number of elements").hasSize(2)
|
||||||
targetManagement.countTargetByFilters(pending, null, null, Boolean.FALSE, targTagD.getName())));
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, setA.getId(),
|
||||||
// Both status: 2 pending and 198 unknown
|
Boolean.FALSE, targTagW.getName())))
|
||||||
assertThat(targetManagement.findTargetByFilters(pageReq, both, null, null, Boolean.FALSE, targTagD.getName())
|
.as("and contains the following elements").containsAll(expected)
|
||||||
.getNumberOfElements()).isEqualTo(200).isEqualTo(Ints.saturatedCast(
|
.as("and filter query returns the same result")
|
||||||
targetManagement.countTargetByFilters(both, null, null, Boolean.FALSE, targTagD.getName())));
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, Boolean.FALSE,
|
||||||
|
targTagW.getName())).as("has number of elements").hasSize(2).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat1TargetWithGivenNameOrDescAndTagAndDSIsInPending(final TargetTag targTagW,
|
||||||
|
final DistributionSet setA, final List<TargetUpdateStatus> pending, final Target expected) {
|
||||||
|
final TargetIdName expectedIdName = convertToIdName(expected);
|
||||||
|
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||||
|
+ setA.getName() + ") and (name==*targ-B* or description==*targ-B*) and tag==" + targTagW.getName();
|
||||||
|
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, pending, "%targ-B%", setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||||
|
.getContent()).as("has number of elements").hasSize(1)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, "%targ-B%",
|
||||||
|
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||||
|
.as("and contains the following elements").containsExactly(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, "%targ-B%", setA.getId(), Boolean.FALSE,
|
||||||
|
targTagW.getName())).as("has number of elements").hasSize(1).as("and contains the following elements")
|
||||||
|
.containsExactly(expectedIdName).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat1TargetWithGivenNameOrDescAndDSIsInPending(final DistributionSet setA,
|
||||||
|
final List<TargetUpdateStatus> pending, final Target expected) {
|
||||||
|
final TargetIdName expectedIdName = convertToIdName(expected);
|
||||||
|
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||||
|
+ setA.getName() + ") and (name==*targ-A* or description==*targ-A*)";
|
||||||
|
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, pending, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
|
||||||
|
.getContent()).as("has number of elements").hasSize(1)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, "%targ-A%",
|
||||||
|
setA.getId(), Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsExactly(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, "%targ-A%", setA.getId(), Boolean.FALSE,
|
||||||
|
new String[0])).as("has number of elements").hasSize(1).as("and contains the following elements")
|
||||||
|
.containsExactly(expectedIdName).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat3TargetsWithGivenDSAreInPending(final DistributionSet setA,
|
||||||
|
final List<TargetUpdateStatus> pending, final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||||
|
+ setA.getName() + ")";
|
||||||
|
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, pending, null, setA.getId(), Boolean.FALSE, new String[0]).getContent())
|
||||||
|
.as("has number of elements").hasSize(3).as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, setA.getId(),
|
||||||
|
Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, setA.getId(), Boolean.FALSE,
|
||||||
|
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat3TargetsAreInStatusPending(final List<TargetUpdateStatus> pending,
|
||||||
|
final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "updatestatus==pending";
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByFilters(pageReq, pending, null, null, Boolean.FALSE, new String[0])
|
||||||
|
.getContent()).as("has number of elements").hasSize(3)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
|
||||||
|
Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(
|
||||||
|
targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, Boolean.FALSE, new String[0]))
|
||||||
|
.as("has number of elements").hasSize(3).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat99TargetsWithGivenNameOrDescAndTagAreInStatusUnknown(final TargetTag targTagW,
|
||||||
|
final List<TargetUpdateStatus> unknown, final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "updatestatus==unknown and (name==*targ-B* or description==*targ-B*) and tag=="
|
||||||
|
+ targTagW.getName();
|
||||||
|
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, unknown, "%targ-B%", null, Boolean.FALSE, targTagW.getName())
|
||||||
|
.getContent()).as("has number of elements").hasSize(99)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, "%targ-B%", null,
|
||||||
|
Boolean.FALSE, targTagW.getName())))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, "%targ-B%", null, Boolean.FALSE,
|
||||||
|
targTagW.getName())).as("has number of elements").hasSize(99).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat99TargetsWithNameOrDescriptionAreInGivenStatus(final List<TargetUpdateStatus> unknown,
|
||||||
|
final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)";
|
||||||
|
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, unknown, "%targ-A%", null, Boolean.FALSE, new String[0]).getContent())
|
||||||
|
.as("has number of elements").hasSize(99).as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, "%targ-A%", null,
|
||||||
|
Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, "%targ-A%", null, Boolean.FALSE,
|
||||||
|
new String[0])).as("has number of elements").hasSize(99).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verfyThat0TargetsAreInStatusUnknownAndHaveDSAssigned(final DistributionSet setA,
|
||||||
|
final List<TargetUpdateStatus> unknown) {
|
||||||
|
final String query = "updatestatus==unknown and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||||
|
+ setA.getName() + ")";
|
||||||
|
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, unknown, null, setA.getId(), Boolean.FALSE, new String[0]).getContent())
|
||||||
|
.as("has number of elements").hasSize(0).as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, setA.getId(),
|
||||||
|
Boolean.FALSE, new String[0])))
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size())
|
||||||
|
.as("and NAMED filter query returns the same result").hasSize(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent().size());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, setA.getId(), Boolean.FALSE,
|
||||||
|
new String[0])).as("has number of elements").hasSize(0)
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findAllTargetIdsByTargetFilterQuery(pageReq, new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat198TargetsAreInStatusUnknownAndHaveGivenTags(final TargetTag targTagY,
|
||||||
|
final TargetTag targTagW, final List<TargetUpdateStatus> unknown, final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName()
|
||||||
|
+ ")";
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByFilters(pageReq, unknown, null, null, Boolean.FALSE, targTagY.getName(),
|
||||||
|
targTagW.getName()).getContent()).as("has number of elements").hasSize(198)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null,
|
||||||
|
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, Boolean.FALSE,
|
||||||
|
targTagY.getName(), targTagW.getName())).as("has number of elements").hasSize(198)
|
||||||
|
.as("and contains the following elements").containsAll(expectedIdNames)
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findAllTargetIdsByTargetFilterQuery(pageReq, new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat397TargetsAreInStatusUnknown(final List<TargetUpdateStatus> unknown,
|
||||||
|
final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "updatestatus==unknown";
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByFilters(pageReq, unknown, null, null, Boolean.FALSE, new String[0])
|
||||||
|
.getContent()).as("has number of elements").hasSize(397)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null,
|
||||||
|
Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(
|
||||||
|
targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, Boolean.FALSE, new String[0]))
|
||||||
|
.as("has number of elements").hasSize(397).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat1TargetWithDescOrNameHasDS(final DistributionSet setA, final Target expected) {
|
||||||
|
final TargetIdName expectedIdName = convertToIdName(expected);
|
||||||
|
final String query = "(name==*targ-A* or description==*targ-A*) and (assignedds.name==" + setA.getName()
|
||||||
|
+ " or installedds.name==" + setA.getName() + ")";
|
||||||
|
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
|
||||||
|
.getContent()).as("has number of elements").hasSize(1)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, "%targ-A%",
|
||||||
|
setA.getId(), Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsExactly(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, "%targ-A%", setA.getId(), Boolean.FALSE,
|
||||||
|
new String[0])).as("has number of elements").hasSize(1).as("and contains the following elements")
|
||||||
|
.containsExactly(expectedIdName).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat3TargetsHaveDSAssigned(final DistributionSet setA, final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName();
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, setA.getId(), Boolean.FALSE, new String[0])
|
||||||
|
.getContent()).as("has number of elements").hasSize(3)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, setA.getId(),
|
||||||
|
Boolean.FALSE, new String[0])))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, setA.getId(), Boolean.FALSE,
|
||||||
|
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat0TargetsWithNameOrdescAndDSHaveTag(final TargetTag targTagX, final DistributionSet setA) {
|
||||||
|
final String query = "(name==*targ-C* or description==*targ-C*) and tag==" + targTagX.getName()
|
||||||
|
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagX.getName())
|
||||||
|
.getContent()).as("has number of elements").hasSize(0)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, "%targ-C%",
|
||||||
|
setA.getId(), Boolean.FALSE, targTagX.getName())))
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size())
|
||||||
|
.as("and NAMED filter query returns the same result").hasSize(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent().size());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, "%targ-C%", setA.getId(), Boolean.FALSE,
|
||||||
|
targTagX.getName())).as("has number of elements").hasSize(0)
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findAllTargetIdsByTargetFilterQuery(pageReq, new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat0TargetsWithTagAndDescOrNameHasDS(final TargetTag targTagW, final DistributionSet setA) {
|
||||||
|
final String query = "(name==*targ-A* or description==*targ-A*) and tag==" + targTagW.getName()
|
||||||
|
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, null, "%targ-A%", setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||||
|
.getContent()).as("has number of elements").hasSize(0)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, "%targ-A%",
|
||||||
|
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size())
|
||||||
|
.as("and NAMED filter query returns the same result").hasSize(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent().size());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, "%targ-A%", setA.getId(), Boolean.FALSE,
|
||||||
|
targTagW.getName())).as("has number of elements").hasSize(0)
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findAllTargetIdsByTargetFilterQuery(pageReq, new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat1TargetHasTagHasDescOrNameAndDs(final TargetTag targTagW, final DistributionSet setA,
|
||||||
|
final Target expected) {
|
||||||
|
final TargetIdName expectedIdName = convertToIdName(expected);
|
||||||
|
final String query = "(name==*targ-c* or description==*targ-C*) and tag==" + targTagW.getName()
|
||||||
|
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
|
||||||
|
assertThat(targetManagement
|
||||||
|
.findTargetByFilters(pageReq, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||||
|
.getContent()).as("has number of elements").hasSize(1)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, "%targ-C%",
|
||||||
|
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||||
|
.as("and contains the following elements").containsExactly(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, "%targ-C%", setA.getId(), Boolean.FALSE,
|
||||||
|
targTagW.getName())).as("has number of elements").hasSize(1).as("and contains the following elements")
|
||||||
|
.containsExactly(expectedIdName).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat100TargetsContainsGivenTextAndHaveTagAssigned(final TargetTag targTagY,
|
||||||
|
final TargetTag targTagW, final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "(name==*targ-B* or description==*targ-B*) and (tag==" + targTagY.getName() + " or tag=="
|
||||||
|
+ targTagW.getName() + ")";
|
||||||
|
assertThat(targetManagement.findTargetByFilters(pageReq, null, "%targ-B%", null, Boolean.FALSE,
|
||||||
|
targTagY.getName(), targTagW.getName()).getContent()).as("has number of elements").hasSize(100)
|
||||||
|
.as("that number is also returned by count query")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, "%targ-B%", null,
|
||||||
|
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, "%targ-B%", null, Boolean.FALSE,
|
||||||
|
targTagY.getName(), targTagW.getName())).as("has number of elements").hasSize(100)
|
||||||
|
.as("and contains the following elements").containsAll(expectedIdNames)
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findAllTargetIdsByTargetFilterQuery(pageReq, new TargetFilterQuery("test", query)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
private final List<Target> concat(final List<Target>... targets) {
|
||||||
|
final List<Target> result = new ArrayList<>();
|
||||||
|
Arrays.asList(targets).forEach(result::addAll);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) {
|
||||||
|
final List<TargetIdName> expectedIdNames = convertToIdNames(expected);
|
||||||
|
final String query = "tag==" + targTagD.getName();
|
||||||
|
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, null, Boolean.FALSE, targTagD.getName())
|
||||||
|
.getContent()).as("Expected number of results is").hasSize(200)
|
||||||
|
.as("and is expected number of results is equal to ")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, null,
|
||||||
|
Boolean.FALSE, targTagD.getName())))
|
||||||
|
.as("and contains the following elements").containsAll(expected)
|
||||||
|
.as("and filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||||
|
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||||
|
.findTargetsAll(new TargetFilterQuery("test", query), pageReq).getContent());
|
||||||
|
|
||||||
|
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, null, Boolean.FALSE,
|
||||||
|
targTagD.getName())).as("has number of elements").hasSize(200).as("and contains the following elements")
|
||||||
|
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||||
|
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||||
|
new TargetFilterQuery("test", query)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Step
|
||||||
|
private void verifyThatRepositoryContains400Targets() {
|
||||||
|
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, null, null, new String[0]).getContent())
|
||||||
|
.as("Overall we expect that many targets in the repository").hasSize(400)
|
||||||
|
.as("which is also reflected by repository count")
|
||||||
|
.hasSize(Ints.saturatedCast(targetManagement.countTargetsAll()))
|
||||||
|
.as("which is also reflected by call without specification")
|
||||||
|
.containsAll(targetManagement.findTargetsAll(pageReq).getContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO kaizimmerm: add filter tests
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the correct order of targets based on selected distribution set. The system expects to have an order based on installed, assigned DS.")
|
@Description("Tests the correct order of targets based on selected distribution set. The system expects to have an order based on installed, assigned DS.")
|
||||||
public void targetSearchWithVariousFilterCombinationsAndOrderByDistributionSet() {
|
public void targetSearchWithVariousFilterCombinationsAndOrderByDistributionSet() {
|
||||||
@@ -205,7 +685,7 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest {
|
|||||||
targInstalled = sendUpdateActionStatusToTargets(ds, targInstalled, Status.FINISHED, "installed");
|
targInstalled = sendUpdateActionStatusToTargets(ds, targInstalled, Status.FINISHED, "installed");
|
||||||
|
|
||||||
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(pageReq, ds.getId(),
|
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(pageReq, ds.getId(),
|
||||||
null, null, null, Boolean.FALSE, null);
|
null, null, null, Boolean.FALSE, new String[0]);
|
||||||
|
|
||||||
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
|
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
|
||||||
|
|
||||||
@@ -222,6 +702,103 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that targets with given assigned DS are returned from repository.")
|
||||||
|
public void findTargetByAssignedDistributionSet() {
|
||||||
|
final DistributionSet assignedSet = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned"));
|
||||||
|
final List<Target> assignedtargets = targetManagement
|
||||||
|
.createTargets(TestDataUtil.generateTargets(10, "assigned"));
|
||||||
|
|
||||||
|
deploymentManagement.assignDistributionSet(assignedSet, assignedtargets);
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(), pageReq))
|
||||||
|
.as("Contains the assigned targets").containsAll(assignedtargets)
|
||||||
|
.as("and that means the following expected amount").hasSize(10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that targets with given assigned DS and additonal specification are returned from repository.")
|
||||||
|
public void findTargetByAssignedDistributionSetWithAdditonalSpecification() {
|
||||||
|
final DistributionSet assignedSet = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
final DistributionSet installedSet = TestDataUtil.generateDistributionSet("another", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned"));
|
||||||
|
final List<Target> assignedtargets = targetManagement
|
||||||
|
.createTargets(TestDataUtil.generateTargets(10, "assigned"));
|
||||||
|
|
||||||
|
// set on installed and assign another one
|
||||||
|
deploymentManagement.assignDistributionSet(installedSet, assignedtargets).getActions().forEach(actionId -> {
|
||||||
|
final Action action = deploymentManagement.findActionWithDetails(actionId);
|
||||||
|
action.setStatus(Status.FINISHED);
|
||||||
|
controllerManagament.addUpdateActionStatus(
|
||||||
|
new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action);
|
||||||
|
});
|
||||||
|
deploymentManagement.assignDistributionSet(assignedSet, assignedtargets);
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(),
|
||||||
|
TargetSpecifications.hasInstalledDistributionSet(installedSet.getId()), pageReq))
|
||||||
|
.as("Contains the assigned targets").containsAll(assignedtargets)
|
||||||
|
.as("and that means the following expected amount").hasSize(10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that targets with given installed DS are returned from repository.")
|
||||||
|
public void findTargetByInstalledDistributionSet() {
|
||||||
|
final DistributionSet assignedSet = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
final DistributionSet installedSet = TestDataUtil.generateDistributionSet("another", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned"));
|
||||||
|
final List<Target> installedtargets = targetManagement
|
||||||
|
.createTargets(TestDataUtil.generateTargets(10, "assigned"));
|
||||||
|
|
||||||
|
// set on installed and assign another one
|
||||||
|
deploymentManagement.assignDistributionSet(installedSet, installedtargets).getActions().forEach(actionId -> {
|
||||||
|
final Action action = deploymentManagement.findActionWithDetails(actionId);
|
||||||
|
action.setStatus(Status.FINISHED);
|
||||||
|
controllerManagament.addUpdateActionStatus(
|
||||||
|
new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action);
|
||||||
|
});
|
||||||
|
deploymentManagement.assignDistributionSet(assignedSet, installedtargets);
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(), pageReq))
|
||||||
|
.as("Contains the assigned targets").containsAll(installedtargets)
|
||||||
|
.as("and that means the following expected amount").hasSize(10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verfies that targets with given installed DS and additonal specification are returned from repository.")
|
||||||
|
public void findTargetByInstalledDistributionSetWithAdditonalSpecification() {
|
||||||
|
final DistributionSet assignedSet = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
final DistributionSet installedSet = TestDataUtil.generateDistributionSet("another", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned"));
|
||||||
|
final List<Target> installedtargets = targetManagement
|
||||||
|
.createTargets(TestDataUtil.generateTargets(10, "assigned"));
|
||||||
|
|
||||||
|
// set on installed and assign another one
|
||||||
|
deploymentManagement.assignDistributionSet(installedSet, installedtargets).getActions().forEach(actionId -> {
|
||||||
|
final Action action = deploymentManagement.findActionWithDetails(actionId);
|
||||||
|
action.setStatus(Status.FINISHED);
|
||||||
|
controllerManagament.addUpdateActionStatus(
|
||||||
|
new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action);
|
||||||
|
});
|
||||||
|
deploymentManagement.assignDistributionSet(assignedSet, installedtargets);
|
||||||
|
|
||||||
|
assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(),
|
||||||
|
TargetSpecifications.hasAssignedDistributionSet(assignedSet.getId()), pageReq))
|
||||||
|
.as("Contains the assigned targets").containsAll(installedtargets)
|
||||||
|
.as("and that means the following expected amount").hasSize(10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private List<Target> sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable<Target> targs,
|
private List<Target> sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable<Target> targs,
|
||||||
final Status status, final String... msgs) {
|
final Status status, final String... msgs) {
|
||||||
final List<Target> result = new ArrayList<Target>();
|
final List<Target> result = new ArrayList<Target>();
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
public void createTargetForTenantWhichDoesNotExistThrowsTenantNotExistException() {
|
public void createTargetForTenantWhichDoesNotExistThrowsTenantNotExistException() {
|
||||||
try {
|
try {
|
||||||
targetManagement.createTarget(new Target("targetId123"));
|
targetManagement.createTarget(new Target("targetId123"));
|
||||||
fail("tenant not exist");
|
fail("should not be possible as the tenant does not exist");
|
||||||
} catch (final TenantNotExistException e) {
|
} catch (final TenantNotExistException e) {
|
||||||
|
// ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +207,12 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Ensures that repositoy returns null if given controller ID does not exist without exception.")
|
||||||
|
public void findTargetByControllerIDWithDetailsReturnsNullForNonexisting() {
|
||||||
|
assertThat(targetManagement.findTargetByControllerIDWithDetails("dsfsdfsdfsd")).as("Expected as").isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Checks if the EntityAlreadyExistsException is thrown if the targets with the same controller ID are created twice.")
|
@Description("Checks if the EntityAlreadyExistsException is thrown if the targets with the same controller ID are created twice.")
|
||||||
public void createMultipleTargetsDuplicate() {
|
public void createMultipleTargetsDuplicate() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -91,13 +92,19 @@ public class TenantConfigurationManagementTest extends AbstractIntegrationTestWi
|
|||||||
.isEqualTo(value2);
|
.isEqualTo(value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TenantConfigurationValidatorException.class)
|
@Test
|
||||||
@Description("Tests that the get configuration throws exception in case the value cannot be automatically converted from String to Boolean")
|
@Description("Tests that the get configuration throws exception in case the value cannot be automatically converted from String to Boolean")
|
||||||
public void wrongTenantConfigurationValueTypeThrowsException() {
|
public void wrongTenantConfigurationValueTypeThrowsException() {
|
||||||
final TenantConfigurationKey configKey = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED;
|
final TenantConfigurationKey configKey = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED;
|
||||||
final String value1 = "thisIsNotABoolean";
|
final String value1 = "thisIsNotABoolean";
|
||||||
|
|
||||||
// add value as String
|
// add value as String
|
||||||
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, value1);
|
try {
|
||||||
|
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, value1);
|
||||||
|
fail("should not have worked as string is not a boolean");
|
||||||
|
} catch (final TenantConfigurationValidatorException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -128,46 +135,71 @@ public class TenantConfigurationManagementTest extends AbstractIntegrationTestWi
|
|||||||
assertThat(tenantConfigurationManagement.getConfigurationValue(configKey, String.class).getValue()).isNull();
|
assertThat(tenantConfigurationManagement.getConfigurationValue(configKey, String.class).getValue()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TenantConfigurationValidatorException.class)
|
@Test
|
||||||
@Description("Test that an Exception is thrown, when an integer is stored but a string expected.")
|
@Description("Test that an Exception is thrown, when an integer is stored but a string expected.")
|
||||||
public void storesIntegerWhenStringIsExpected() {
|
public void storesIntegerWhenStringIsExpected() {
|
||||||
final TenantConfigurationKey configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME;
|
final TenantConfigurationKey configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME;
|
||||||
final Integer wrongDataype = 123;
|
final Integer wrongDataype = 123;
|
||||||
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataype);
|
try {
|
||||||
|
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataype);
|
||||||
|
fail("should not have worked as integer is not a string");
|
||||||
|
} catch (final TenantConfigurationValidatorException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TenantConfigurationValidatorException.class)
|
@Test
|
||||||
@Description("Test that an Exception is thrown, when an integer is stored but a boolean expected.")
|
@Description("Test that an Exception is thrown, when an integer is stored but a boolean expected.")
|
||||||
public void storesIntegerWhenBooleanIsExpected() {
|
public void storesIntegerWhenBooleanIsExpected() {
|
||||||
final TenantConfigurationKey configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED;
|
final TenantConfigurationKey configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED;
|
||||||
final Integer wrongDataype = 123;
|
final Integer wrongDataype = 123;
|
||||||
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataype);
|
try {
|
||||||
|
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataype);
|
||||||
|
fail("should not have worked as integer is not a boolean");
|
||||||
|
} catch (final TenantConfigurationValidatorException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TenantConfigurationValidatorException.class)
|
@Test
|
||||||
@Description("Test that an Exception is thrown, when an integer is stored as PollingTime.")
|
@Description("Test that an Exception is thrown, when an integer is stored as PollingTime.")
|
||||||
public void storesIntegerWhenPollingIntervalIsExpected() {
|
public void storesIntegerWhenPollingIntervalIsExpected() {
|
||||||
final TenantConfigurationKey configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
final TenantConfigurationKey configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||||
final Integer wrongDataype = 123;
|
final Integer wrongDataype = 123;
|
||||||
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataype);
|
try {
|
||||||
|
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataype);
|
||||||
|
fail("should not have worked as integer is not a time field");
|
||||||
|
} catch (final TenantConfigurationValidatorException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TenantConfigurationValidatorException.class)
|
@Test
|
||||||
@Description("Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime.")
|
@Description("Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime.")
|
||||||
public void storesWrongFormattedStringAsPollingInterval() {
|
public void storesWrongFormattedStringAsPollingInterval() {
|
||||||
final TenantConfigurationKey configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
final TenantConfigurationKey configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||||
final String wrongFormatted = "wrongFormatted";
|
final String wrongFormatted = "wrongFormatted";
|
||||||
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongFormatted);
|
try {
|
||||||
|
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongFormatted);
|
||||||
|
fail("should not have worked as string is not a time field");
|
||||||
|
} catch (final TenantConfigurationValidatorException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TenantConfigurationValidatorException.class)
|
@Test
|
||||||
@Description("Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime.")
|
@Description("Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime.")
|
||||||
public void storesTooSmallDurationAsPollingInterval() {
|
public void storesTooSmallDurationAsPollingInterval() {
|
||||||
final TenantConfigurationKey configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
final TenantConfigurationKey configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||||
|
|
||||||
final String tooSmallDuration = DurationHelper
|
final String tooSmallDuration = DurationHelper
|
||||||
.durationToFormattedString(DurationHelper.getDurationByTimeValues(0, 0, 1));
|
.durationToFormattedString(DurationHelper.getDurationByTimeValues(0, 0, 1));
|
||||||
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, tooSmallDuration);
|
try {
|
||||||
|
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, tooSmallDuration);
|
||||||
|
fail("should not have worked as string has an invalid format");
|
||||||
|
} catch (final TenantConfigurationValidatorException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -35,18 +35,18 @@ public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void seuptBeforeTest() {
|
public void seuptBeforeTest() {
|
||||||
|
|
||||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("DS", softwareManagement,
|
DistributionSet ds = TestDataUtil.generateDistributionSet("DS", softwareManagement, distributionSetManagement);
|
||||||
distributionSetManagement);
|
|
||||||
ds.setDescription("DS");
|
ds.setDescription("DS");
|
||||||
ds.getMetadata().add(new DistributionSetMetadata("metaKey", ds, "metaValue"));
|
ds = distributionSetManagement.updateDistributionSet(ds);
|
||||||
distributionSetManagement.updateDistributionSet(ds);
|
distributionSetManagement
|
||||||
|
.createDistributionSetMetadata(new DistributionSetMetadata("metaKey", ds, "metaValue"));
|
||||||
|
|
||||||
final DistributionSet ds2 = TestDataUtil
|
DistributionSet ds2 = TestDataUtil
|
||||||
.generateDistributionSets("NewDS", 3, softwareManagement, distributionSetManagement).get(0);
|
.generateDistributionSets("NewDS", 3, softwareManagement, distributionSetManagement).get(0);
|
||||||
|
|
||||||
ds2.setDescription("DS%");
|
ds2.setDescription("DS%");
|
||||||
ds2.getMetadata().add(new DistributionSetMetadata("metaKey", ds2, "value"));
|
ds2 = distributionSetManagement.updateDistributionSet(ds2);
|
||||||
distributionSetManagement.updateDistributionSet(ds2);
|
distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata("metaKey", ds2, "value"));
|
||||||
|
|
||||||
final DistributionSetTag targetTag = tagManagement.createDistributionSetTag(new DistributionSetTag("Tag1"));
|
final DistributionSetTag targetTag = tagManagement.createDistributionSetTag(new DistributionSetTag("Tag1"));
|
||||||
tagManagement.createDistributionSetTag(new DistributionSetTag("Tag2"));
|
tagManagement.createDistributionSetTag(new DistributionSetTag("Tag2"));
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ package org.eclipse.hawkbit.repository.rsql;
|
|||||||
|
|
||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
||||||
@@ -35,13 +38,13 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractIntegrationTe
|
|||||||
final DistributionSet distributionSet = TestDataUtil.generateDistributionSet("DS", softwareManagement,
|
final DistributionSet distributionSet = TestDataUtil.generateDistributionSet("DS", softwareManagement,
|
||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
distributionSetId = distributionSet.getId();
|
distributionSetId = distributionSet.getId();
|
||||||
|
|
||||||
|
final List<DistributionSetMetadata> metadata = new ArrayList<>();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
final DistributionSetMetadata distributionSetMetadata = new DistributionSetMetadata("" + i, distributionSet,
|
metadata.add(new DistributionSetMetadata("" + i, distributionSet, "" + i));
|
||||||
"" + i);
|
|
||||||
distributionSet.getMetadata().add(distributionSetMetadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
distributionSetManagement.updateDistributionSet(distributionSet);
|
distributionSetManagement.createDistributionSetMetadata(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
public class RSQLSoftwareModuleFieldTest extends AbstractIntegrationTest {
|
public class RSQLSoftwareModuleFieldTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void seuptBeforeTest() {
|
public void setupBeforeTest() {
|
||||||
|
|
||||||
final SoftwareModule ah = softwareManagement
|
final SoftwareModule ah = softwareManagement
|
||||||
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", "agent-hub", ""));
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", "agent-hub", ""));
|
||||||
softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", "aa", ""));
|
softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", "aa", ""));
|
||||||
@@ -40,14 +39,9 @@ public class RSQLSoftwareModuleFieldTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
final SoftwareModuleMetadata softwareModuleMetadata = new SoftwareModuleMetadata("metaKey", ah, "metaValue");
|
final SoftwareModuleMetadata softwareModuleMetadata = new SoftwareModuleMetadata("metaKey", ah, "metaValue");
|
||||||
softwareManagement.createSoftwareModuleMetadata(softwareModuleMetadata);
|
softwareManagement.createSoftwareModuleMetadata(softwareModuleMetadata);
|
||||||
ah.getMetadata().add(softwareModuleMetadata);
|
|
||||||
softwareManagement.updateSoftwareModule(ah);
|
|
||||||
|
|
||||||
final SoftwareModuleMetadata softwareModuleMetadata2 = new SoftwareModuleMetadata("metaKey", ah2, "value");
|
final SoftwareModuleMetadata softwareModuleMetadata2 = new SoftwareModuleMetadata("metaKey", ah2, "value");
|
||||||
softwareManagement.createSoftwareModuleMetadata(softwareModuleMetadata2);
|
softwareManagement.createSoftwareModuleMetadata(softwareModuleMetadata2);
|
||||||
ah2.getMetadata().add(softwareModuleMetadata2);
|
|
||||||
softwareManagement.updateSoftwareModule(ah2);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ package org.eclipse.hawkbit.repository.rsql;
|
|||||||
|
|
||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields;
|
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields;
|
||||||
@@ -37,13 +40,13 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractIntegrationTes
|
|||||||
"application", "1.0.0", "Desc", "vendor Limited, California"));
|
"application", "1.0.0", "Desc", "vendor Limited, California"));
|
||||||
softwareModuleId = softwareModule.getId();
|
softwareModuleId = softwareModule.getId();
|
||||||
|
|
||||||
|
final List<SoftwareModuleMetadata> metadata = new ArrayList<>();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
final SoftwareModuleMetadata metadata = new SoftwareModuleMetadata("" + i, softwareModule, "" + i);
|
metadata.add(new SoftwareModuleMetadata("" + i, softwareModule, "" + i));
|
||||||
softwareModule.getMetadata().add(metadata);
|
|
||||||
softwareModuleMetadataRepository.save(metadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
softwareManagement.updateSoftwareModule(softwareModule);
|
softwareManagement.createSoftwareModuleMetadata(metadata);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetReques
|
|||||||
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -87,7 +86,7 @@ public interface DistributionSetTagRestApi {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
|
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
|
||||||
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<TagsRest> createDistributionSetTags(@RequestBody final List<TagRequestBodyPut> tags);
|
public ResponseEntity<List<TagRest>> createDistributionSetTags(@RequestBody final List<TagRequestBodyPut> tags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import org.eclipse.hawkbit.rest.resource.model.PagedList;
|
|||||||
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -85,7 +84,7 @@ public interface TargetTagRestApi {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
|
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
|
||||||
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<TagsRest> createTargetTags(@RequestBody final List<TagRequestBodyPut> tags);
|
public ResponseEntity<List<TagRest>> createTargetTags(@RequestBody final List<TagRequestBodyPut> tags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
/**
|
/**
|
||||||
* A json annotated rest model for Action to RESTful API representation.
|
* A json annotated rest model for Action to RESTful API representation.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@JsonInclude(Include.NON_NULL)
|
@JsonInclude(Include.NON_NULL)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
|||||||
@@ -1,276 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.rest.resource.model.action;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A json annotated rest model for Actions to RESTful API representation.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ActionsRest extends ResourceSupport implements List<ActionRest> {
|
|
||||||
|
|
||||||
private final List<ActionRest> delegate = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#size()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return delegate.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#isEmpty()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return delegate.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#contains(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean contains(final Object o) {
|
|
||||||
return delegate.contains(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#iterator()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Iterator<ActionRest> iterator() {
|
|
||||||
return delegate.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#toArray()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Object[] toArray() {
|
|
||||||
return delegate.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param a
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#toArray(java.lang.Object[])
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <T> T[] toArray(final T[] a) {
|
|
||||||
return delegate.toArray(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param e
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#add(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean add(final ActionRest e) {
|
|
||||||
return delegate.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#remove(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean remove(final Object o) {
|
|
||||||
return delegate.remove(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#containsAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean containsAll(final Collection<?> c) {
|
|
||||||
return delegate.containsAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#addAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean addAll(final Collection<? extends ActionRest> c) {
|
|
||||||
return delegate.addAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#addAll(int, java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean addAll(final int index, final Collection<? extends ActionRest> c) {
|
|
||||||
return delegate.addAll(index, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#removeAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean removeAll(final Collection<?> c) {
|
|
||||||
return delegate.removeAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#retainAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean retainAll(final Collection<?> c) {
|
|
||||||
return delegate.retainAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see java.util.List#clear()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
delegate.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
return delegate.equals(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return delegate.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#get(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ActionRest get(final int index) {
|
|
||||||
return delegate.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @param element
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#set(int, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ActionRest set(final int index, final ActionRest element) {
|
|
||||||
return delegate.set(index, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @param element
|
|
||||||
* @see java.util.List#add(int, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void add(final int index, final ActionRest element) {
|
|
||||||
delegate.add(index, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#remove(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ActionRest remove(final int index) {
|
|
||||||
return delegate.remove(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#indexOf(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int indexOf(final Object o) {
|
|
||||||
return delegate.indexOf(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#lastIndexOf(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int lastIndexOf(final Object o) {
|
|
||||||
return delegate.lastIndexOf(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#listIterator()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ListIterator<ActionRest> listIterator() {
|
|
||||||
return delegate.listIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#listIterator(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ListIterator<ActionRest> listIterator(final int index) {
|
|
||||||
return delegate.listIterator(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fromIndex
|
|
||||||
* @param toIndex
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#subList(int, int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<ActionRest> subList(final int fromIndex, final int toIndex) {
|
|
||||||
return delegate.subList(fromIndex, toIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.rest.resource.model.tag;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List representation of the {@link TagRest} because Spring MVC cannot handle
|
|
||||||
* plain lists interfaces as request body.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TagsRest extends ResourceSupport implements List<TagRest> {
|
|
||||||
|
|
||||||
private final List<TagRest> delegate = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#size()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return delegate.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#isEmpty()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return delegate.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#contains(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean contains(final Object o) {
|
|
||||||
return delegate.contains(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#iterator()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Iterator<TagRest> iterator() {
|
|
||||||
return delegate.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#toArray()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Object[] toArray() {
|
|
||||||
return delegate.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param a
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#toArray(java.lang.Object[])
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <T> T[] toArray(final T[] a) {
|
|
||||||
return delegate.toArray(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param e
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#add(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean add(final TagRest e) {
|
|
||||||
return delegate.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#remove(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean remove(final Object o) {
|
|
||||||
return delegate.remove(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#containsAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean containsAll(final Collection<?> c) {
|
|
||||||
return delegate.containsAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#addAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean addAll(final Collection<? extends TagRest> c) {
|
|
||||||
return delegate.addAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#addAll(int, java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean addAll(final int index, final Collection<? extends TagRest> c) {
|
|
||||||
return delegate.addAll(index, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#removeAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean removeAll(final Collection<?> c) {
|
|
||||||
return delegate.removeAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#retainAll(java.util.Collection)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean retainAll(final Collection<?> c) {
|
|
||||||
return delegate.retainAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see java.util.List#clear()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
delegate.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
return delegate.equals(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return delegate.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#get(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TagRest get(final int index) {
|
|
||||||
return delegate.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @param element
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#set(int, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TagRest set(final int index, final TagRest element) {
|
|
||||||
return delegate.set(index, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @param element
|
|
||||||
* @see java.util.List#add(int, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void add(final int index, final TagRest element) {
|
|
||||||
delegate.add(index, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#remove(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TagRest remove(final int index) {
|
|
||||||
return delegate.remove(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#indexOf(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int indexOf(final Object o) {
|
|
||||||
return delegate.indexOf(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param o
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#lastIndexOf(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int lastIndexOf(final Object o) {
|
|
||||||
return delegate.lastIndexOf(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#listIterator()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ListIterator<TagRest> listIterator() {
|
|
||||||
return delegate.listIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#listIterator(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ListIterator<TagRest> listIterator(final int index) {
|
|
||||||
return delegate.listIterator(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fromIndex
|
|
||||||
* @param toIndex
|
|
||||||
* @return
|
|
||||||
* @see java.util.List#subList(int, int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<TagRest> subList(final int fromIndex, final int toIndex) {
|
|
||||||
return delegate.subList(fromIndex, toIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ import org.eclipse.hawkbit.repository.TagManagement;
|
|||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||||
import org.eclipse.hawkbit.rest.resource.api.DistributionSetTagRestApi;
|
import org.eclipse.hawkbit.rest.resource.api.DistributionSetTagRestApi;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.PagedList;
|
import org.eclipse.hawkbit.rest.resource.model.PagedList;
|
||||||
@@ -26,7 +26,6 @@ import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetReques
|
|||||||
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -86,7 +85,7 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<TagsRest> createDistributionSetTags(final List<TagRequestBodyPut> tags) {
|
public ResponseEntity<List<TagRest>> createDistributionSetTags(final List<TagRequestBodyPut> tags) {
|
||||||
LOG.debug("creating {} ds tags", tags.size());
|
LOG.debug("creating {} ds tags", tags.size());
|
||||||
|
|
||||||
final List<DistributionSetTag> createdTags = this.tagManagement
|
final List<DistributionSetTag> createdTags = this.tagManagement
|
||||||
@@ -135,7 +134,7 @@ public class DistributionSetTagResource implements DistributionSetTagRestApi {
|
|||||||
|
|
||||||
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResult assigmentResult = this.distributionSetManagement
|
final DistributionSetTagAssignmentResult assigmentResult = this.distributionSetManagement
|
||||||
.toggleTagAssignment(findDistributionSetIds(assignedDSRequestBodies), tag.getName());
|
.toggleTagAssignment(findDistributionSetIds(assignedDSRequestBodies), tag.getName());
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest();
|
final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest();
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI {
|
|||||||
// check if distribution set exists otherwise throw exception
|
// check if distribution set exists otherwise throw exception
|
||||||
// immediately
|
// immediately
|
||||||
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||||
final SoftwareModuleMetadata findOne = softwareManagement.findOne(new SwMetadataCompositeKey(sw, metadataKey));
|
final SoftwareModuleMetadata findOne = softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sw, metadataKey));
|
||||||
return ResponseEntity.<MetadataRest> ok(SoftwareModuleMapper.toResponseSwMetadata(findOne));
|
return ResponseEntity.<MetadataRest> ok(SoftwareModuleMapper.toResponseSwMetadata(findOne));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class SoftwareModuleTypeResource implements SoftwareModuleTypeRestApi {
|
|||||||
final List<SoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
|
final List<SoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
|
||||||
|
|
||||||
final List<SoftwareModuleType> createdSoftwareModules = this.softwareManagement
|
final List<SoftwareModuleType> createdSoftwareModules = this.softwareManagement
|
||||||
.createSoftwareModuleTypes(SoftwareModuleTypeMapper.smFromRequest(softwareModuleTypes));
|
.createSoftwareModuleType(SoftwareModuleTypeMapper.smFromRequest(softwareModuleTypes));
|
||||||
|
|
||||||
return new ResponseEntity<>(SoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
|
return new ResponseEntity<>(SoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
|
||||||
HttpStatus.CREATED);
|
HttpStatus.CREATED);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class SystemManagementResource {
|
|||||||
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
|
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
|
||||||
|
|
||||||
result.setTenantStats(
|
result.setTenantStats(
|
||||||
report.getTenants().stream().map(tenant -> convertTenant(tenant)).collect(Collectors.toList()));
|
report.getTenants().stream().map(SystemManagementResource::convertTenant).collect(Collectors.toList()));
|
||||||
|
|
||||||
return ResponseEntity.ok(result);
|
return ResponseEntity.ok(result);
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ public class SystemManagementResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all caches containing currently.
|
* Returns a list of all caches.
|
||||||
*
|
*
|
||||||
* @return a list of caches for all tenants
|
* @return a list of caches for all tenants
|
||||||
*/
|
*/
|
||||||
@@ -112,8 +112,8 @@ public class SystemManagementResource {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||||
public ResponseEntity<Collection<CacheRest>> getCaches() {
|
public ResponseEntity<Collection<CacheRest>> getCaches() {
|
||||||
final Collection<String> cacheNames = cacheManager.getCacheNames();
|
final Collection<String> cacheNames = cacheManager.getCacheNames();
|
||||||
return ResponseEntity.ok(cacheNames.stream().map(cacheName -> cacheManager.getCache(cacheName))
|
return ResponseEntity
|
||||||
.map(cache -> cacheRest(cache)).collect(Collectors.toList()));
|
.ok(cacheNames.stream().map(cacheManager::getCache).map(this::cacheRest).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.eclipse.hawkbit.rest.resource.api.DistributionSetTagRestApi;
|
|||||||
import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi;
|
import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapper which maps repository model to RESTful model representation and
|
* A mapper which maps repository model to RESTful model representation and
|
||||||
@@ -33,8 +32,8 @@ final class TagMapper {
|
|||||||
// Utility class
|
// Utility class
|
||||||
}
|
}
|
||||||
|
|
||||||
static TagsRest toResponse(final List<TargetTag> targetTags) {
|
static List<TagRest> toResponse(final List<TargetTag> targetTags) {
|
||||||
final TagsRest tagsRest = new TagsRest();
|
final List<TagRest> tagsRest = new ArrayList<>();
|
||||||
if (targetTags == null) {
|
if (targetTags == null) {
|
||||||
return tagsRest;
|
return tagsRest;
|
||||||
}
|
}
|
||||||
@@ -63,8 +62,8 @@ final class TagMapper {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TagsRest toResponseDistributionSetTag(final List<DistributionSetTag> distributionSetTags) {
|
static List<TagRest> toResponseDistributionSetTag(final List<DistributionSetTag> distributionSetTags) {
|
||||||
final TagsRest tagsRest = new TagsRest();
|
final List<TagRest> tagsRest = new ArrayList<>();
|
||||||
if (distributionSetTags == null) {
|
if (distributionSetTags == null) {
|
||||||
return tagsRest;
|
return tagsRest;
|
||||||
}
|
}
|
||||||
@@ -131,7 +130,5 @@ final class TagMapper {
|
|||||||
if (response.getName() != null) {
|
if (response.getName() != null) {
|
||||||
tag.setName(response.getName());
|
tag.setName(response.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import org.eclipse.hawkbit.rest.resource.api.TargetRestApi;
|
|||||||
import org.eclipse.hawkbit.rest.resource.model.PollStatusRest;
|
import org.eclipse.hawkbit.rest.resource.model.PollStatusRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.action.ActionRest;
|
import org.eclipse.hawkbit.rest.resource.model.action.ActionRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.action.ActionStatusRest;
|
import org.eclipse.hawkbit.rest.resource.model.action.ActionStatusRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.action.ActionsRest;
|
|
||||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||||
|
|
||||||
@@ -214,8 +213,8 @@ public final class TargetMapper {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ActionsRest toResponse(final String targetId, final List<Action> actions) {
|
static List<ActionRest> toResponse(final String targetId, final List<Action> actions) {
|
||||||
final ActionsRest mappedList = new ActionsRest();
|
final List<ActionRest> mappedList = new ArrayList<>();
|
||||||
|
|
||||||
for (final Action action : actions) {
|
for (final Action action : actions) {
|
||||||
final ActionRest response = toResponse(targetId, action, action.isActive());
|
final ActionRest response = toResponse(targetId, action, action.isActive());
|
||||||
|
|||||||
@@ -17,14 +17,13 @@ import org.eclipse.hawkbit.repository.TargetManagement;
|
|||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||||
import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi;
|
import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.PagedList;
|
import org.eclipse.hawkbit.rest.resource.model.PagedList;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
|
||||||
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -87,7 +86,7 @@ public class TargetTagResource implements TargetTagRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<TagsRest> createTargetTags(@RequestBody final List<TagRequestBodyPut> tags) {
|
public ResponseEntity<List<TagRest>> createTargetTags(@RequestBody final List<TagRequestBodyPut> tags) {
|
||||||
LOG.debug("creating {} target tags", tags.size());
|
LOG.debug("creating {} target tags", tags.size());
|
||||||
final List<TargetTag> createdTargetTags = this.tagManagement
|
final List<TargetTag> createdTargetTags = this.tagManagement
|
||||||
.createTargetTags(TagMapper.mapTargeTagFromRequest(tags));
|
.createTargetTags(TagMapper.mapTargeTagFromRequest(tags));
|
||||||
@@ -130,7 +129,7 @@ public class TargetTagResource implements TargetTagRestApi {
|
|||||||
LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
||||||
|
|
||||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||||
final TargetTagAssigmentResult assigmentResult = this.targetManagement
|
final TargetTagAssignmentResult assigmentResult = this.targetManagement
|
||||||
.toggleTagAssignment(findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName());
|
.toggleTagAssignment(findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName());
|
||||||
|
|
||||||
final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest();
|
final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest();
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
|
|||||||
artifactManagement
|
artifactManagement
|
||||||
.loadLocalArtifactBinary((LocalArtifact) softwareManagement
|
.loadLocalArtifactBinary((LocalArtifact) softwareManagement
|
||||||
.findSoftwareModuleWithDetails(sm.getId()).getArtifacts().get(0))
|
.findSoftwareModuleWithDetails(sm.getId()).getArtifacts().get(0))
|
||||||
.getFileInputStream()));
|
.getFileInputStream()));
|
||||||
|
|
||||||
// hashes
|
// hashes
|
||||||
assertThat(artifactManagement.findLocalArtifactByFilename("origFilename").get(0).getSha1Hash())
|
assertThat(artifactManagement.findLocalArtifactByFilename("origFilename").get(0).getSha1Hash())
|
||||||
@@ -773,12 +773,12 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
|
|||||||
.andExpect(jsonPath("[2].createdBy", equalTo("uploadTester")))
|
.andExpect(jsonPath("[2].createdBy", equalTo("uploadTester")))
|
||||||
.andExpect(jsonPath("[2].createdAt", not(equalTo(0)))).andReturn();
|
.andExpect(jsonPath("[2].createdAt", not(equalTo(0)))).andReturn();
|
||||||
|
|
||||||
final SoftwareModule osCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name1", "version1")
|
final SoftwareModule osCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name1", "version1",
|
||||||
.get(0);
|
osType);
|
||||||
final SoftwareModule jvmCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name2", "version1")
|
final SoftwareModule jvmCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name2", "version1",
|
||||||
.get(0);
|
runtimeType);
|
||||||
final SoftwareModule ahCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name3", "version1")
|
final SoftwareModule ahCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name3", "version1",
|
||||||
.get(0);
|
appType);
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||||
@@ -930,8 +930,10 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
|
|||||||
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
|
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
|
||||||
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
||||||
|
|
||||||
final SoftwareModuleMetadata metaKey1 = softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey1));
|
final SoftwareModuleMetadata metaKey1 = softwareManagement
|
||||||
final SoftwareModuleMetadata metaKey2 = softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey2));
|
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey1));
|
||||||
|
final SoftwareModuleMetadata metaKey2 = softwareManagement
|
||||||
|
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey2));
|
||||||
|
|
||||||
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
|
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
|
||||||
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
|
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
|
||||||
@@ -957,7 +959,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
|
|||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
||||||
|
|
||||||
final SoftwareModuleMetadata assertDS = softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey));
|
final SoftwareModuleMetadata assertDS = softwareManagement
|
||||||
|
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
|
||||||
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,7 +979,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
softwareManagement.findOne(new SwMetadataCompositeKey(sm, knownKey));
|
softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
|
||||||
fail("expected EntityNotFoundException but didn't throw");
|
fail("expected EntityNotFoundException but didn't throw");
|
||||||
} catch (final EntityNotFoundException e) {
|
} catch (final EntityNotFoundException e) {
|
||||||
// ok as expected
|
// ok as expected
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.rest.resource.model;
|
package org.eclipse.hawkbit.rest.resource.model;
|
||||||
|
|
||||||
import static org.fest.assertions.Assertions.assertThat;
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -23,10 +24,14 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
@Stories("Paged List Handling")
|
@Stories("Paged List Handling")
|
||||||
public class PagedListTest {
|
public class PagedListTest {
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test
|
||||||
@Description("Ensures that a null payload entitiy throws an exception.")
|
@Description("Ensures that a null payload entitiy throws an exception.")
|
||||||
public void createListWithNullContentThrowsException() {
|
public void createListWithNullContentThrowsException() {
|
||||||
new PagedList<>(null, 0);
|
try {
|
||||||
|
new PagedList<>(null, 0);
|
||||||
|
fail("as content is null");
|
||||||
|
} catch (final NullPointerException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
|
||||||
import com.vaadin.event.FieldEvents.TextChangeListener;
|
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
@@ -245,27 +243,21 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addDescriptionTextChangeListener() {
|
private void addDescriptionTextChangeListener() {
|
||||||
descTextArea.addTextChangeListener(new TextChangeListener() {
|
descTextArea.addTextChangeListener(event -> {
|
||||||
@Override
|
if (event.getText().equals(oldDescriptionValue) && vendorTextField.getValue().equals(oldVendorValue)) {
|
||||||
public void textChange(final TextChangeEvent event) {
|
saveSoftware.setEnabled(false);
|
||||||
if (event.getText().equals(oldDescriptionValue) && vendorTextField.getValue().equals(oldVendorValue)) {
|
} else {
|
||||||
saveSoftware.setEnabled(false);
|
saveSoftware.setEnabled(true);
|
||||||
} else {
|
|
||||||
saveSoftware.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addVendorTextChangeListener() {
|
private void addVendorTextChangeListener() {
|
||||||
vendorTextField.addTextChangeListener(new TextChangeListener() {
|
vendorTextField.addTextChangeListener(event -> {
|
||||||
@Override
|
if (event.getText().equals(oldVendorValue) && descTextArea.getValue().equals(oldDescriptionValue)) {
|
||||||
public void textChange(final TextChangeEvent event) {
|
saveSoftware.setEnabled(false);
|
||||||
if (event.getText().equals(oldVendorValue) && descTextArea.getValue().equals(oldDescriptionValue)) {
|
} else {
|
||||||
saveSoftware.setEnabled(false);
|
saveSoftware.setEnabled(true);
|
||||||
} else {
|
|
||||||
saveSoftware.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -280,7 +272,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
final String description = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
final String description = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||||
final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
|
final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
|
||||||
if (mandatoryCheck(name, version, type)) {
|
if (mandatoryCheck(name, version, type)) {
|
||||||
if (HawkbitCommonUtil.isDuplicate(name, version)) {
|
if (HawkbitCommonUtil.isDuplicate(name, version, type)) {
|
||||||
uiNotifcation.displayValidationError(
|
uiNotifcation.displayValidationError(
|
||||||
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
|||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
import org.eclipse.hawkbit.repository.TagManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
|
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
|
||||||
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
||||||
@@ -100,7 +100,7 @@ public class DistributionTagToken extends AbstractTagToken {
|
|||||||
@Override
|
@Override
|
||||||
protected void assignTag(final String tagNameSelected) {
|
protected void assignTag(final String tagNameSelected) {
|
||||||
if (tagNameSelected != null) {
|
if (tagNameSelected != null) {
|
||||||
final DistributionSetTagAssigmentResult result = toggleAssignment(tagNameSelected);
|
final DistributionSetTagAssignmentResult result = toggleAssignment(tagNameSelected);
|
||||||
if (result.getAssigned() >= 1 && NOTAGS_SELECTED) {
|
if (result.getAssigned() >= 1 && NOTAGS_SELECTED) {
|
||||||
eventBus.publish(this, ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG);
|
eventBus.publish(this, ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG);
|
||||||
}
|
}
|
||||||
@@ -109,10 +109,10 @@ public class DistributionTagToken extends AbstractTagToken {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetTagAssigmentResult toggleAssignment(final String tagNameSelected) {
|
private DistributionSetTagAssignmentResult toggleAssignment(final String tagNameSelected) {
|
||||||
final Set<Long> distributionList = new HashSet<>();
|
final Set<Long> distributionList = new HashSet<>();
|
||||||
distributionList.add(selectedDS.getId());
|
distributionList.add(selectedDS.getId());
|
||||||
final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
|
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
|
||||||
tagNameSelected);
|
tagNameSelected);
|
||||||
uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n));
|
uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n));
|
||||||
return result;
|
return result;
|
||||||
@@ -120,7 +120,7 @@ public class DistributionTagToken extends AbstractTagToken {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void unassignTag(final String tagName) {
|
protected void unassignTag(final String tagName) {
|
||||||
final DistributionSetTagAssigmentResult result = toggleAssignment(tagName);
|
final DistributionSetTagAssignmentResult result = toggleAssignment(tagName);
|
||||||
if (result.getUnassigned() >= 1 && (isClickedTagListEmpty() || getClickedTagList().contains(tagName))) {
|
if (result.getUnassigned() >= 1 && (isClickedTagListEmpty() || getClickedTagList().contains(tagName))) {
|
||||||
eventBus.publish(this, ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG);
|
eventBus.publish(this, ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG);
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ public class DistributionTagToken extends AbstractTagToken {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onTargetTagAssigmentResultEvent(final DistributionSetTagAssigmentResultEvent event) {
|
void onTargetTagAssigmentResultEvent(final DistributionSetTagAssigmentResultEvent event) {
|
||||||
final DistributionSetTagAssigmentResult assignmentResult = event.getAssigmentResult();
|
final DistributionSetTagAssignmentResult assignmentResult = event.getAssigmentResult();
|
||||||
final DistributionSetTag tag = assignmentResult.getDistributionSetTag();
|
final DistributionSetTag tag = assignmentResult.getDistributionSetTag();
|
||||||
if (isAssign(assignmentResult)) {
|
if (isAssign(assignmentResult)) {
|
||||||
addNewToken(tag.getId());
|
addNewToken(tag.getId());
|
||||||
@@ -212,7 +212,7 @@ public class DistributionTagToken extends AbstractTagToken {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAssign(final DistributionSetTagAssigmentResult assignmentResult) {
|
protected boolean isAssign(final DistributionSetTagAssignmentResult assignmentResult) {
|
||||||
if (assignmentResult.getAssigned() > 0) {
|
if (assignmentResult.getAssigned() > 0) {
|
||||||
final List<Long> assignedDsNames = assignmentResult.getAssignedDs().stream().map(t -> t.getId())
|
final List<Long> assignedDsNames = assignmentResult.getAssignedDs().stream().map(t -> t.getId())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -223,7 +223,7 @@ public class DistributionTagToken extends AbstractTagToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isUnassign(final DistributionSetTagAssigmentResult assignmentResult) {
|
protected boolean isUnassign(final DistributionSetTagAssignmentResult assignmentResult) {
|
||||||
if (assignmentResult.getUnassigned() > 0) {
|
if (assignmentResult.getUnassigned() > 0) {
|
||||||
final List<Long> assignedDsNames = assignmentResult.getUnassignedDs().stream().map(t -> t.getId())
|
final List<Long> assignedDsNames = assignmentResult.getUnassignedDs().stream().map(t -> t.getId())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent;
|
|||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
|
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
||||||
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
|
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
|
||||||
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
|
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
|
||||||
@@ -68,7 +68,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
|
|||||||
@Override
|
@Override
|
||||||
protected void assignTag(final String tagNameSelected) {
|
protected void assignTag(final String tagNameSelected) {
|
||||||
if (tagNameSelected != null) {
|
if (tagNameSelected != null) {
|
||||||
final TargetTagAssigmentResult result = toggleAssignment(tagNameSelected);
|
final TargetTagAssignmentResult result = toggleAssignment(tagNameSelected);
|
||||||
if (result.getAssigned() >= 1 && NOTAGS_SELECTED) {
|
if (result.getAssigned() >= 1 && NOTAGS_SELECTED) {
|
||||||
eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG);
|
eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG);
|
||||||
}
|
}
|
||||||
@@ -77,17 +77,17 @@ public class TargetTagToken extends AbstractTargetTagToken {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TargetTagAssigmentResult toggleAssignment(final String tagNameSelected) {
|
private TargetTagAssignmentResult toggleAssignment(final String tagNameSelected) {
|
||||||
final Set<String> targetList = new HashSet<>();
|
final Set<String> targetList = new HashSet<>();
|
||||||
targetList.add(selectedTarget.getControllerId());
|
targetList.add(selectedTarget.getControllerId());
|
||||||
final TargetTagAssigmentResult result = targetManagement.toggleTagAssignment(targetList, tagNameSelected);
|
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, tagNameSelected);
|
||||||
uinotification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(tagNameSelected, result, i18n));
|
uinotification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(tagNameSelected, result, i18n));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void unassignTag(final String tagName) {
|
protected void unassignTag(final String tagName) {
|
||||||
final TargetTagAssigmentResult result = toggleAssignment(tagName);
|
final TargetTagAssignmentResult result = toggleAssignment(tagName);
|
||||||
if (result.getUnassigned() >= 1 && (isClickedTagListEmpty() || getClickedTagList().contains(tagName))) {
|
if (result.getUnassigned() >= 1 && (isClickedTagListEmpty() || getClickedTagList().contains(tagName))) {
|
||||||
eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG);
|
eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG);
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onTargetTagAssigmentResultEvent(final TargetTagAssigmentResultEvent event) {
|
void onTargetTagAssigmentResultEvent(final TargetTagAssigmentResultEvent event) {
|
||||||
final TargetTagAssigmentResult assignmentResult = event.getAssigmentResult();
|
final TargetTagAssignmentResult assignmentResult = event.getAssigmentResult();
|
||||||
final TargetTag targetTag = assignmentResult.getTargetTag();
|
final TargetTag targetTag = assignmentResult.getTargetTag();
|
||||||
if (isAssign(assignmentResult)) {
|
if (isAssign(assignmentResult)) {
|
||||||
addNewToken(targetTag.getId());
|
addNewToken(targetTag.getId());
|
||||||
@@ -149,7 +149,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAssign(final TargetTagAssigmentResult assignmentResult) {
|
protected boolean isAssign(final TargetTagAssignmentResult assignmentResult) {
|
||||||
if (assignmentResult.getAssigned() > 0) {
|
if (assignmentResult.getAssigned() > 0) {
|
||||||
final List<String> assignedTargetNames = assignmentResult.getAssignedTargets().stream()
|
final List<String> assignedTargetNames = assignmentResult.getAssignedTargets().stream()
|
||||||
.map(t -> t.getControllerId()).collect(Collectors.toList());
|
.map(t -> t.getControllerId()).collect(Collectors.toList());
|
||||||
@@ -160,7 +160,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isUnassign(final TargetTagAssigmentResult assignmentResult) {
|
protected boolean isUnassign(final TargetTagAssignmentResult assignmentResult) {
|
||||||
if (assignmentResult.getUnassigned() > 0) {
|
if (assignmentResult.getUnassigned() > 0) {
|
||||||
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedTargets().stream()
|
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedTargets().stream()
|
||||||
.map(t -> t.getControllerId()).collect(Collectors.toList());
|
.map(t -> t.getControllerId()).collect(Collectors.toList());
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
|
||||||
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
|
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
|
||||||
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||||
|
|
||||||
@@ -79,9 +77,8 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
|
|||||||
final Slice<CustomSoftwareModule> swModuleBeans;
|
final Slice<CustomSoftwareModule> swModuleBeans;
|
||||||
final List<ProxyBaseSwModuleItem> proxyBeans = new ArrayList<>();
|
final List<ProxyBaseSwModuleItem> proxyBeans = new ArrayList<>();
|
||||||
|
|
||||||
swModuleBeans = getSoftwareManagement().findSoftwareModuleOrderByDistribution(
|
swModuleBeans = getSoftwareManagement().findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||||
new OffsetBasedPageRequest(startIndex, count, new Sort(Direction.ASC, "name", "version")),
|
new OffsetBasedPageRequest(startIndex, count), orderByDistId, searchText, type);
|
||||||
orderByDistId, searchText, type);
|
|
||||||
|
|
||||||
for (final CustomSoftwareModule swModule : swModuleBeans) {
|
for (final CustomSoftwareModule swModule : swModuleBeans) {
|
||||||
proxyBeans.add(getProxyBean(swModule));
|
proxyBeans.add(getProxyBean(swModule));
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user