diff --git a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java
index fb961f9b2..eb4cacf33 100644
--- a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java
+++ b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java
@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.security;
import static org.fest.assertions.Assertions.assertThat;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
import org.junit.Test;
@@ -20,6 +21,7 @@ import org.springframework.security.authentication.InsufficientAuthenticationExc
import org.springframework.security.core.Authentication;
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.Stories;
@@ -38,11 +40,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
@Mock
private TenantAwareWebAuthenticationDetails webAuthenticationDetailsMock;
- /**
- * Testing in case the containing controllerId in the URI request path does
- * not accord with the controllerId in the request header.
- */
- @Test(expected = BadCredentialsException.class)
+ @Test
+ @Description("Testing in case the containing controllerId in the URI request path does not accord with the controllerId in the request header.")
public void principalAndCredentialsNotTheSameThrowsAuthenticationException() {
final String principal = "controllerIdURL";
final String credentials = "controllerIdHeader";
@@ -51,15 +50,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
token.setDetails(webAuthenticationDetailsMock);
// 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
+ @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() {
final String principal = "controllerId";
final String credentials = "controllerId";
@@ -71,12 +72,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
assertThat(authenticate.isAuthenticated()).isTrue();
}
- /**
- * 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.
- */
- @Test(expected = InsufficientAuthenticationException.class)
+ @Test
+ @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.")
public void priniciapAndCredentialsAreTheSameButSourceIpRequestNotMatching() {
final String remoteAddress = "192.168.1.1";
final String principal = "controllerId";
@@ -88,16 +85,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
when(webAuthenticationDetailsMock.getRemoteAddress()).thenReturn(remoteAddress);
// 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) {
+
+ }
}
- /**
- * 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.
- */
- @Test()
+ @Test
+ @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.")
public void priniciapAndCredentialsAreTheSameAndSourceIpIsTrusted() {
final String principal = "controllerId";
final String credentials = "controllerId";
@@ -112,7 +110,7 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
assertThat(authenticate.isAuthenticated()).isTrue();
}
- @Test()
+ @Test
public void priniciapAndCredentialsAreTheSameAndSourceIpIsWithinList() {
final String[] trustedIPAddresses = new String[] { "192.168.1.1", "192.168.1.2", REQUEST_SOURCE_IP,
"192.168.1.3" };
@@ -148,6 +146,11 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
// test, should throw authentication exception
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) {
+
+ }
}
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java
index bf805f3dd..8ef427dcf 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java
@@ -13,8 +13,8 @@ import java.util.Map;
import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler;
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.model.helper.AfterTransactionCommitExecutorHolder;
import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder;
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
@@ -127,23 +127,11 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
return new ExceptionMappingAspectHandler();
}
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
- * createJpaVendorAdapter()
- */
@Override
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
return new EclipseLinkJpaVendorAdapter();
}
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
- * getVendorProperties()
- */
@Override
protected Map getVendorProperties() {
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java
index 75145778e..3824ae80f 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java
@@ -167,11 +167,6 @@ public class ExceptionMappingAspectHandler implements Ordered {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.core.Ordered#getOrder()
- */
@Override
public int getOrder() {
return 1;
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityPropertyChangeListener.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityPropertyChangeListener.java
index 5fd4ba27d..28b5e677c 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityPropertyChangeListener.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityPropertyChangeListener.java
@@ -18,9 +18,9 @@ import org.eclipse.hawkbit.eventbus.event.RolloutGroupPropertyChangeEvent;
import org.eclipse.hawkbit.eventbus.event.RolloutPropertyChangeEvent;
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
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.RolloutGroup;
+import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
import org.eclipse.persistence.descriptors.DescriptorEvent;
@@ -36,13 +36,7 @@ import com.google.common.eventbus.EventBus;
*
*/
public class EntityPropertyChangeListener extends DescriptorEventAdapter {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.persistence.descriptors.DescriptorEventAdapter#postInsert
- * (org.eclipse.persistence.descriptors.DescriptorEvent)
- */
+
@Override
public void postInsert(final DescriptorEvent event) {
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
public void postUpdate(final DescriptorEvent event) {
if (event.getObject().getClass().equals(Action.class)) {
- getAfterTransactionCommmitExecutor().afterCommit(
- () -> getEventBus()
- .post(new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class,
- event))));
+ getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
+ new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class, event))));
} else if (event.getObject().getClass().equals(Rollout.class)) {
- getAfterTransactionCommmitExecutor().afterCommit(
- () -> getEventBus().post(
- new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class,
- event))));
+ getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
+ new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class, event))));
} else if (event.getObject().getClass().equals(RolloutGroup.class)) {
getAfterTransactionCommmitExecutor().afterCommit(
- () -> getEventBus().post(
- new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(), getChangeSet(
- RolloutGroup.class, event))));
+ () -> getEventBus().post(new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(),
+ getChangeSet(RolloutGroup.class, event))));
}
}
@@ -87,14 +69,11 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
final Class clazz, final DescriptorEvent event) {
final T rolloutGroup = clazz.cast(event.getObject());
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
- return changeSet
- .getChanges()
- .stream()
- .filter(record -> record instanceof DirectToFieldChangeRecord)
+ return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
.map(record -> (DirectToFieldChangeRecord) record)
- .collect(
- Collectors.toMap(record -> record.getAttribute(), record -> new AbstractPropertyChangeEvent(
- rolloutGroup, null).new Values(record.getOldValue(), record.getNewValue())));
+ .collect(Collectors.toMap(record -> record.getAttribute(),
+ record -> new AbstractPropertyChangeEvent(rolloutGroup, null).new Values(
+ record.getOldValue(), record.getNewValue())));
}
private AfterTransactionCommitExecutor getAfterTransactionCommmitExecutor() {
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractBaseEntityEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractBaseEntityEvent.java
index 15864eb8f..d27669ade 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractBaseEntityEvent.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractBaseEntityEvent.java
@@ -11,8 +11,9 @@ package org.eclipse.hawkbit.eventbus.event;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/**
- * An abstract definition class for {@link EntityEvent} for {@link TenantAwareBaseEntity}s,
- * which holds the {@link TenantAwareBaseEntity}.
+ * An abstract definition class for {@link EntityEvent} for
+ * {@link TenantAwareBaseEntity}s, which holds the {@link TenantAwareBaseEntity}
+ * .
*
*
*
@@ -37,33 +38,16 @@ public abstract class AbstractBaseEntityEvent e
this.entity = baseEntity;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity()
- */
@Override
public E getEntity() {
return entity;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity(java.lang
- * .Class)
- */
@Override
public T getEntity(final Class entityClass) {
return entityClass.cast(entity);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getTenant()
- */
@Override
public String getTenant() {
return entity.getTenant();
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java
index 9a8a485b4..e10b9a51f 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java
@@ -8,14 +8,14 @@
*/
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.
*/
public class DistributionSetTagAssigmentResultEvent {
- private final DistributionSetTagAssigmentResult assigmentResult;
+ private final DistributionSetTagAssignmentResult assigmentResult;
/**
* Constructor.
@@ -23,11 +23,11 @@ public class DistributionSetTagAssigmentResultEvent {
* @param assigmentResult
* the assignment result-
*/
- public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssigmentResult assigmentResult) {
+ public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult) {
this.assigmentResult = assigmentResult;
}
- public DistributionSetTagAssigmentResult getAssigmentResult() {
+ public DistributionSetTagAssignmentResult getAssigmentResult() {
return assigmentResult;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java
index 405595de0..6bdc3aebd 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java
@@ -8,14 +8,14 @@
*/
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.
*/
public class TargetTagAssigmentResultEvent {
- private final TargetTagAssigmentResult assigmentResult;
+ private final TargetTagAssignmentResult assigmentResult;
/**
* Constructor.
@@ -23,11 +23,11 @@ public class TargetTagAssigmentResultEvent {
* @param assigmentResult
* the assignment result-
*/
- public TargetTagAssigmentResultEvent(final TargetTagAssigmentResult assigmentResult) {
+ public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult) {
this.assigmentResult = assigmentResult;
}
- public TargetTagAssigmentResult getAssigmentResult() {
+ public TargetTagAssignmentResult getAssigmentResult() {
return assigmentResult;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java
index 7131bbe0a..0bb94bd72 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java
@@ -376,16 +376,9 @@ public class ControllerManagement {
switch (actionStatus.getStatus()) {
case ERROR:
mergedTarget = deploymentManagement.updateTargetInfo(mergedTarget, TargetUpdateStatus.ERROR, false);
- // set action inactive
- mergedAction.setActive(false);
- mergedAction.setStatus(Status.ERROR);
- mergedTarget.setAssignedDistributionSet(null);
- targetManagement.updateTarget(mergedTarget);
+ handleErrorOnAction(mergedAction, mergedTarget);
break;
case FINISHED:
- // set action inactive
- mergedAction.setActive(false);
- mergedAction.setStatus(Status.FINISHED);
handleFinishedAndStoreInTargetStatus(mergedTarget, mergedAction);
break;
case CANCELED:
@@ -404,6 +397,13 @@ public class ControllerManagement {
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) {
if (securityProperties.getDos().getMaxStatusEntriesPerAction() > 0) {
@@ -420,6 +420,8 @@ public class ControllerManagement {
}
private void handleFinishedAndStoreInTargetStatus(final Target target, final Action action) {
+ action.setActive(false);
+ action.setStatus(Status.FINISHED);
final TargetInfo targetInfo = target.getTargetInfo();
final DistributionSet ds = entityManager.merge(action.getDistributionSet());
targetInfo.setInstalledDistributionSet(ds);
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java
index 3e61e4499..8b1df00da 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java
@@ -55,7 +55,7 @@ public class DistributionSetAssignmentResult extends AssignmentResult {
* @return the assignedTargets
*/
public List getAssignedTargets() {
- return targetManagement.findTargetsByControllerID(assignedTargets);
+ return targetManagement.findTargetByControllerID(assignedTargets);
}
/**
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java
index 8df29956b..8bee7c703 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java
@@ -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.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.DistributionSetTypeElement;
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.
*
- *
- *
- *
*/
@Transactional(readOnly = true)
@Validated
@@ -140,15 +137,15 @@ public class DistributionSetManagement {
* @param sets
* to toggle for
* @param tag
- * to toogle
- * @return {@link DistributionSetTagAssigmentResult} with all metadata of
+ * to toggle
+ * @return {@link DistributionSetTagAssignmentResult} with all meta data of
* the assignment outcome.
*/
@Modifying
@Transactional
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
- public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final List sets,
+ public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final List sets,
@NotNull final DistributionSetTag tag) {
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
}
@@ -163,42 +160,43 @@ public class DistributionSetManagement {
* to toggle for
* @param tagName
* to toggle
- * @return {@link DistributionSetTagAssigmentResult} with all metadata of
+ * @return {@link DistributionSetTagAssignmentResult} with all meta data of
* the assignment outcome.
*/
@Modifying
@Transactional
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
- public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection dsIds,
+ public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection dsIds,
@NotNull final String tagName) {
final Iterable sets = findDistributionSetListWithDetails(dsIds);
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
- DistributionSetTagAssigmentResult result;
- final List allDSs = new ArrayList<>();
+ DistributionSetTagAssignmentResult result;
+ final List toBeChangedDSs = new ArrayList<>();
for (final DistributionSet set : sets) {
if (set.getTags().add(myTag)) {
- allDSs.add(set);
+ toBeChangedDSs.add(set);
}
}
- // unassigment case
- if (allDSs.isEmpty()) {
+ // un-assignment case
+ if (toBeChangedDSs.isEmpty()) {
for (final DistributionSet set : sets) {
if (set.getTags().remove(myTag)) {
- allDSs.add(set);
+ toBeChangedDSs.add(set);
}
}
- result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(),
- Collections.emptyList(), distributionSetRepository.save(allDSs), myTag);
+ result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), 0,
+ toBeChangedDSs.size(), Collections.emptyList(), distributionSetRepository.save(toBeChangedDSs),
+ myTag);
} else {
- result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0,
- distributionSetRepository.save(allDSs), Collections.emptyList(), myTag);
+ result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), toBeChangedDSs.size(),
+ 0, distributionSetRepository.save(toBeChangedDSs), Collections.emptyList(), myTag);
}
- final DistributionSetTagAssigmentResult resultAssignment = result;
+ final DistributionSetTagAssignmentResult resultAssignment = result;
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
// no reason to persist the tag
@@ -351,6 +349,9 @@ public class DistributionSetManagement {
public List createDistributionSets(@NotNull final Iterable distributionSets) {
for (final DistributionSet ds : distributionSets) {
prepareDsSave(ds);
+ if (ds.getType() == null) {
+ ds.setType(systemManagement.getTenantMetadata().getDefaultDsType());
+ }
}
return distributionSetRepository.save(distributionSets);
}
@@ -436,7 +437,7 @@ public class DistributionSetManagement {
* @param spec
* of the search
* @param pageable
- * parametsr for paging
+ * parameter for paging
*
* @return the found {@link SoftwareModuleType}s
*/
@@ -761,7 +762,7 @@ public class DistributionSetManagement {
if (distributionSetMetadataRepository.exists(metadata.getId())) {
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
// modifying metadata is modifying the base distribution set itself for
// auditing purposes.
@@ -915,7 +916,7 @@ public class DistributionSetManagement {
@Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
public List createDistributionSetTypes(@NotNull final Collection 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(() -> {
- final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0,
+ final DistributionSetTagAssignmentResult result = new DistributionSetTagAssignmentResult(0, save.size(), 0,
save, Collections.emptyList(), tag);
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
});
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java
index 79f54a3f0..0624f269a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java
@@ -29,9 +29,6 @@ import org.springframework.stereotype.Repository;
* Workaround as spring data does not provide a {@link Slice} based
* {@link JpaRepository#findAll()}.
*
- *
- *
- *
*/
@Repository
public class NoCountPagingRepository {
@@ -104,15 +101,6 @@ public class NoCountPagingRepository {
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
protected Page readPage(final TypedQuery query, final Pageable pageable, final Specification spec) {
query.setFirstResult(pageable.getOffset());
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java
index eab926b4b..b95664d8f 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java
@@ -458,11 +458,6 @@ public class ReportManagement {
return name;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
@@ -471,11 +466,6 @@ public class ReportManagement {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is
// generated
@@ -499,11 +489,6 @@ public class ReportManagement {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return "DSName [name=" + name + "]";
@@ -523,9 +508,6 @@ public class ReportManagement {
/**
* Return DateTypes.
- *
- *
- *
*/
public static final class DateTypes implements Serializable {
/**
@@ -585,12 +567,6 @@ public class ReportManagement {
private static final long serialVersionUID = 1L;
private static final String DATE_PATTERN = "yyyy-MM";
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
- * format(java. lang.String)
- */
@Override
public LocalDate format(final String s) {
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
@@ -598,23 +574,11 @@ public class ReportManagement {
return ym.atDay(1);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
- * h2Format()
- */
@Override
public String h2Format() {
return DATE_PATTERN;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
- * mySqlFormat( )
- */
@Override
public String mySqlFormat() {
return "%Y-%m";
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java
index 1f610d29c..c6eab402a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java
@@ -59,11 +59,7 @@ import com.google.common.base.Strings;
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)
@@ -99,7 +95,7 @@ public class SoftwareManagement {
private ArtifactManagement artifactManagement;
/**
- * Updates existing {@link SoftwareModule}. Updateable values are
+ * Updates existing {@link SoftwareModule}. Update-able values are
* {@link SoftwareModule#getDescription()}
* {@link SoftwareModule#getVendor()}.
*
@@ -119,17 +115,21 @@ public class SoftwareManagement {
final SoftwareModule module = softwareModuleRepository.findOne(sm.getId());
+ boolean updated = false;
if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) {
module.setDescription(sm.getDescription());
+ updated = true;
}
if (null == sm.getVendor() || !sm.getVendor().equals(module.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#getColour()}.
*
@@ -145,13 +145,16 @@ public class SoftwareManagement {
final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
+ boolean updated = false;
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
type.setDescription(sm.getDescription());
+ updated = true;
}
if (sm.getColour() != null && !sm.getColour().equals(type.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}
* @param version
* of the {@link SoftwareModule}
- * @return the found {@link SoftwareModule}s
+ * @param type
+ * of the {@link SoftwareModule}
+ * @return the found {@link SoftwareModule} or null
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
- public List findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
- @NotEmpty final String version) {
+ public SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
+ @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
* {@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
* page parameter
* @param orderByDistributionId
- * the ID of distribution set to be order by
+ * the ID of distribution set to be ordered on top
* @param searchText
- * to be filtered as "like" on {@link SoftwareModule#getName()}
+ * filtered as "like" on {@link SoftwareModule#getName()}
* @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}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
- public Slice findSoftwareModuleOrderByDistribution(@NotNull final Pageable pageable,
- @NotNull final Long orderByDistributionId, final String searchText, final SoftwareModuleType type) {
+ public Slice findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
+ @NotNull final Pageable pageable, @NotNull final Long orderByDistributionId, final String searchText,
+ final SoftwareModuleType type) {
final List resultList = new ArrayList<>();
final int pageSize = pageable.getPageSize();
@@ -522,7 +533,7 @@ public class SoftwareManagement {
assignedRoot, assignedQuery, cb,
cb.equal(assignedDsJoin.get(DistributionSet_.id), orderByDistributionId));
// if we have some predicates then add it to the where clause of the
- // multiselect
+ // multi select
assignedQuery.where(specPredicate);
assignedQuery.orderBy(cb.asc(assignedRoot.get(SoftwareModule_.name)),
cb.asc(assignedRoot.get(SoftwareModule_.version)));
@@ -546,7 +557,7 @@ public class SoftwareManagement {
unassignedQuery.distinct(true);
final Root unassignedRoot = unassignedQuery.from(SoftwareModule.class);
- Predicate[] unassignedSpec = null;
+ Predicate[] unassignedSpec;
if (!assignedSoftwareModules.isEmpty()) {
unassignedSpec = specificationsToPredicate(buildSpecificationList(searchText, type), unassignedRoot,
unassignedQuery, cb, cb.not(unassignedRoot.get(SoftwareModule_.id)
@@ -709,8 +720,8 @@ public class SoftwareManagement {
@Modifying
@Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
- public List createSoftwareModuleTypes(@NotNull final Collection types) {
- return types.stream().map(type -> createSoftwareModuleType(type)).collect(Collectors.toList());
+ public List createSoftwareModuleType(@NotNull final Collection types) {
+ return types.stream().map(this::createSoftwareModuleType).collect(Collectors.toList());
}
/**
@@ -826,7 +837,7 @@ public class SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) {
// 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
// software module
// indirectly
@@ -884,7 +895,7 @@ public class SoftwareManagement {
cb) -> cb.and(
cb.equal(root.get(SoftwareModuleMetadata_.softwareModule)
.get(SoftwareModule_.id), softwareModuleId),
- spec.toPredicate(root, query, cb)),
+ spec.toPredicate(root, query, cb)),
pageable);
}
@@ -899,7 +910,7 @@ public class SoftwareManagement {
* in case the meta data does not exists for the given key
*/
@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);
if (findOne == null) {
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleRepository.java
index ccadb028a..d70e8226f 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleRepository.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleRepository.java
@@ -43,15 +43,19 @@ public interface SoftwareModuleRepository
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
* to be filtered on
* @param version
* 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 findByNameAndVersion(String name, String version);
+ SoftwareModule findOneByNameAndVersionAndType(String name, String version, SoftwareModuleType type);
/**
* deletes the {@link SoftwareModule}s with the given IDs.
@@ -81,6 +85,8 @@ public interface SoftwareModuleRepository
Page findByAssignedTo(Pageable pageable, DistributionSet set);
/**
+ *
+ *
* @param set
* to search for
* @return all {@link SoftwareModule}s that are assigned to given
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java
index 559b71498..5577e1d61 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java
@@ -310,8 +310,6 @@ public class SystemManagement {
}
private DistributionSetType createStandardSoftwareDataSetup() {
-
- // Edge Controller Linux standard setup
final SoftwareModuleType eclApp = softwareModuleTypeRepository.save(new SoftwareModuleType("application",
"ECL Application", "Edge Controller Linux base application type", 1));
final SoftwareModuleType eclOs = softwareModuleTypeRepository
@@ -341,18 +339,8 @@ public class SystemManagement {
* default types we need to use the tenant the current tenant which is
* currently created and not the one currently in the {@link TenantAware}.
*
- *
- *
*/
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
public Object generate(final Object target, final Method method, final Object... params) {
final String initialTenantCreation = createInitialTenant.get();
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java
index e790d0a5e..0e0e474b2 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java
@@ -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.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.Target_;
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.cache.annotation.CacheEvict;
import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
@@ -74,8 +73,6 @@ import com.google.common.eventbus.EventBus;
/**
* Business service facade for managing {@link Target}s.
*
- *
- *
*/
@Transactional(readOnly = true)
@Validated
@@ -157,7 +154,7 @@ public class TargetManagement {
* @return List of found{@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
- public List findTargetsByControllerID(@NotEmpty final Collection controllerIDs) {
+ public List findTargetByControllerID(@NotEmpty final Collection 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
- * {@link Target#getActiveActions()} possible including the filtering based
- * on the given {@code spec}.
+ * {@link Target#getActiveActions()} possible including additional filtering
+ * based on the given {@code spec}.
*
* @param distributionSetID
* the ID of the {@link DistributionSet}
@@ -376,7 +373,8 @@ public class TargetManagement {
/**
* retrieves {@link Target}s by the installed {@link DistributionSet}without
* 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
* the ID of the {@link DistributionSet}
@@ -492,7 +490,7 @@ public class TargetManagement {
if (!Strings.isNullOrEmpty(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));
}
return specList;
@@ -536,7 +534,7 @@ public class TargetManagement {
@Transactional
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
- public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final List targets,
+ public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final List targets,
@NotNull final TargetTag tag) {
return toggleTagAssignment(
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
@@ -558,7 +556,7 @@ public class TargetManagement {
@Transactional
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
- public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection targetIds,
+ public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection targetIds,
@NotNull final String tagName) {
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
final List alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
@@ -568,7 +566,7 @@ public class TargetManagement {
// all are already assigned -> unassign
if (alreadyAssignedTargets.size() == allTargets.size()) {
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);
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
@@ -578,7 +576,7 @@ public class TargetManagement {
allTargets.removeAll(alreadyAssignedTargets);
// some or none are assigned -> assign
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);
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
@@ -609,7 +607,7 @@ public class TargetManagement {
final List save = targetRepository.save(allTargets);
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);
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
});
@@ -622,7 +620,7 @@ public class TargetManagement {
final List save = targetRepository.save(targets);
afterCommit.afterCommit(() -> {
- final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, 0, save.size(),
+ final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, 0, save.size(),
Collections.emptyList(), save, tag);
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
* 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 null in case this
- * is not required.
+ *
* @param filterByStatus
* find targets having this {@link TargetUpdateStatus}s. Set to
* null in case this is not required.
@@ -827,28 +823,38 @@ public class TargetManagement {
* to find targets having the text anywhere in name or
* description. Set null in case this is not
* required.
+ * @param installedOrAssignedDistributionSetId
+ * to find targets having the {@link DistributionSet} as
+ * installed or assigned. Set to null in case this
+ * is not required.
* @param filterByTagNames
* to find targets which are having any one in this tag names.
* Set null in case this is not required.
* @param selectTargetWithNoTag
* 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)
- public List findAllTargetIdsByFilters(final PageRequest pageRequest,
- final Long filterByDistributionId, final Collection filterByStatus,
- final String filterBySearchText, final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
+ public List findAllTargetIdsByFilters(@NotNull final Pageable pageRequest,
+ final Collection filterByStatus, final String filterBySearchText,
+ final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag,
+ final String... filterByTagNames) {
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery
*
- *
- *
- *
- *
*/
@Entity
@Table(name = "sp_distribution_set", uniqueConstraints = {
@@ -67,14 +63,14 @@ public class DistributionSet extends NamedVersionedEntity {
@ManyToMany(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
@JoinTable(name = "sp_ds_module", joinColumns = {
- @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 = "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")) })
private final Set modules = new HashSet<>();
@ManyToMany(targetEntity = DistributionSetTag.class)
@JoinTable(name = "sp_ds_dstag", joinColumns = {
- @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 = "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")) })
private Set tags = new HashSet<>();
@Column(name = "deleted")
@@ -95,7 +91,7 @@ public class DistributionSet extends NamedVersionedEntity {
private final List metadata = new ArrayList<>();
@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;
@Column(name = "complete")
@@ -130,39 +126,30 @@ public class DistributionSet extends NamedVersionedEntity {
if (moduleList != null) {
moduleList.forEach(this::addModule);
}
- complete = type.checkComplete(this);
+ if (this.type != null) {
+ complete = this.type.checkComplete(this);
+ }
}
public Set getTags() {
return tags;
}
- /**
- * @return the deleted
- */
public boolean isDeleted() {
return deleted;
}
/**
- * @return the metadata
+ * @return immutable list of meta data elements.
*/
public List getMetadata() {
- return metadata;
+ return Collections.unmodifiableList(metadata);
}
- /**
- * @return the actions
- */
public List getActions() {
return actions;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
@@ -171,16 +158,8 @@ public class DistributionSet extends NamedVersionedEntity {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
@@ -195,10 +174,6 @@ public class DistributionSet extends NamedVersionedEntity {
return requiredMigrationStep;
}
- /**
- * @param deleted
- * the deleted to set
- */
public DistributionSet setDeleted(final boolean deleted) {
this.deleted = deleted;
return this;
@@ -209,10 +184,6 @@ public class DistributionSet extends NamedVersionedEntity {
return this;
}
- /**
- * @param tags
- * the tags to set
- */
public DistributionSet setTags(final Set tags) {
this.tags = tags;
return this;
@@ -232,11 +203,6 @@ public class DistributionSet extends NamedVersionedEntity {
return installedAtTargets;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
@@ -322,7 +288,7 @@ public class DistributionSet extends NamedVersionedEntity {
* Searches through modules for the given type.
*
* @param type
- * to seach for
+ * to search for
* @return SoftwareModule of given type or null if not in the
* list.
*/
@@ -337,26 +303,15 @@ public class DistributionSet extends NamedVersionedEntity {
return null;
}
- /**
- * @return the type
- */
public DistributionSetType getType() {
return type;
}
- /**
- * @param type
- * the type to set
- */
public void setType(final DistributionSetType type) {
this.type = type;
}
- /**
- * @return the complete
- */
public boolean isComplete() {
return complete;
}
-
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetIdName.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetIdName.java
index a7eb8e517..f8662567a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetIdName.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetIdName.java
@@ -15,9 +15,6 @@ import java.io.Serializable;
*
*/
public class DistributionSetIdName implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private final Long id;
@@ -39,9 +36,6 @@ public class DistributionSetIdName implements Serializable {
this.version = version;
}
- /**
- * @return the id
- */
public Long getId() {
return id;
}
@@ -50,40 +44,27 @@ public class DistributionSetIdName implements Serializable {
return version;
}
- /**
- * @return the name
- */
public String getName() {
return name;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
- public int hashCode() { // NOSONAR - as this is generated
+ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (id == null ? 0 : id.hashCode());
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
- public boolean equals(final Object obj) { // NOSONAR - as this is generated
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof DistributionSetIdName)) {
return false;
}
final DistributionSetIdName other = (DistributionSetIdName) obj;
@@ -97,11 +78,6 @@ public class DistributionSetIdName implements Serializable {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java
index b0627f0db..7b2e637b9 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java
@@ -23,20 +23,13 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
- * Metadata for {@link DistributionSet}.
- *
- *
- *
+ * Meta data for {@link DistributionSet}.
*
*/
@IdClass(DsMetadataCompositeKey.class)
@Entity
@Table(name = "sp_ds_metadata")
public class DistributionSetMetadata implements Serializable {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
@Id
@@ -49,11 +42,11 @@ public class DistributionSetMetadata implements Serializable {
@Id
@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;
public DistributionSetMetadata() {
-
+ // Default constructor for JPA.
}
/**
@@ -73,49 +66,66 @@ public class DistributionSetMetadata implements Serializable {
return new DsMetadataCompositeKey(distributionSet, key);
}
- /**
- * @return the key
- */
public String getKey() {
return key;
}
- /**
- * @param key
- * the key to set
- */
public void setKey(final String key) {
this.key = key;
}
- /**
- * @param distributionSet
- * the distributionSet to set
- */
public void setDistributionSet(final DistributionSet distributionSet) {
this.distributionSet = distributionSet;
}
- /**
- * @return the value
- */
public String getValue() {
return value;
}
- /**
- * @param value
- * the value to set
- */
public void setValue(final String value) {
this.value = value;
}
- /**
- * @return the distributionSet
- */
public DistributionSet getDistributionSet() {
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;
+ }
+
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java
index 63a858a7d..137fde5b9 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java
@@ -21,16 +21,11 @@ import javax.persistence.UniqueConstraint;
* A {@link DistributionSetTag} is used to describe DistributionSet attributes
* and use them also for filtering the DistributionSet list.
*
- *
- *
- *
- *
- *
*/
@Entity
@Table(name = "sp_distributionset_tag", indexes = {
@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 {
private static final long serialVersionUID = 1L;
@@ -69,11 +64,6 @@ public class DistributionSetTag extends Tag {
return assignedToDistributionSet;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
@@ -82,16 +72,8 @@ public class DistributionSetTag extends Tag {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssigmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssignmentResult.java
similarity index 80%
rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssigmentResult.java
rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssignmentResult.java
index d7ed57305..eddd10c1b 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssigmentResult.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssignmentResult.java
@@ -11,10 +11,10 @@ package org.eclipse.hawkbit.repository.model;
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 List assignedDs;
@@ -37,7 +37,7 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
* @param distributionSetTag
* 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 assignedDs, final List unassignedDs,
final DistributionSetTag distributionSetTag) {
super(assigned, alreadyAssigned);
@@ -47,30 +47,18 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
this.distributionSetTag = distributionSetTag;
}
- /**
- * @return the unassigned
- */
public int getUnassigned() {
return unassigned;
}
- /**
- * @return the distributionSetTag
- */
public DistributionSetTag getDistributionSetTag() {
return distributionSetTag;
}
- /**
- * @return the assignedDs
- */
public List getAssignedDs() {
return assignedDs;
}
- /**
- * @return the unassignedDs
- */
public List getUnassignedDs() {
return unassignedDs;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java
index e1c7e61ea..f7dc791a4 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java
@@ -27,9 +27,6 @@ import javax.persistence.UniqueConstraint;
* A distribution set type defines which software module types can or have to be
* {@link DistributionSet}.
*
- *
- *
- *
*/
@Entity
@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 = { "type_key", "tenant" }, name = "uk_dst_key") })
public class DistributionSetType extends NamedEntity {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
@OneToMany(targetEntity = DistributionSetTypeElement.class, cascade = {
@@ -59,7 +52,7 @@ public class DistributionSetType extends NamedEntity {
private boolean deleted = false;
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) {
super(name, description);
this.key = key;
- this.colour = color;
+ colour = color;
}
/**
@@ -256,17 +249,10 @@ public class DistributionSetType extends NamedEntity {
return this;
}
- /**
- * @return the key
- */
public String getKey() {
return key;
}
- /**
- * @param key
- * the key to set
- */
public void setKey(final String key) {
this.key = key;
}
@@ -282,19 +268,10 @@ public class DistributionSetType extends NamedEntity {
.containsAll(getMandatoryModuleTypes());
}
- /**
- *
- * @return the DistributionSet type color
- */
public String getColour() {
return colour;
}
- /**
- *
- * @param colour
- * the col
- */
public void setColour(final String colour) {
this.colour = colour;
}
@@ -303,14 +280,29 @@ public class DistributionSetType extends NamedEntity {
return elements;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
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;
+ }
+
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElement.java
index 0d892f6da..8414a6f1a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElement.java
@@ -25,17 +25,10 @@ import javax.persistence.Table;
* Relation element between a {@link DistributionSetType} and its
* {@link SoftwareModuleType} elements.
*
- *
- *
- *
*/
@Entity
@Table(name = "sp_ds_type_element")
public class DistributionSetTypeElement implements Serializable {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
@EmbeddedId
@@ -46,18 +39,16 @@ public class DistributionSetTypeElement implements Serializable {
@MapsId("dsType")
@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;
@MapsId("smType")
@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;
- /**
- * Default constructor.
- */
public DistributionSetTypeElement() {
+ // Default constructor for JPA
}
/**
@@ -74,38 +65,30 @@ public class DistributionSetTypeElement implements Serializable {
public DistributionSetTypeElement(final DistributionSetType dsType, final SoftwareModuleType smType,
final boolean mandatory) {
super();
- this.key = new DistributionSetTypeElementCompositeKey(dsType, smType);
+ key = new DistributionSetTypeElementCompositeKey(dsType, smType);
this.dsType = dsType;
this.smType = smType;
this.mandatory = mandatory;
}
- /**
- * @return the mandatory
- */
public boolean isMandatory() {
return mandatory;
}
- /**
- * @return the dsType
- */
public DistributionSetType getDsType() {
return dsType;
}
- /**
- * @return the smType
- */
public SoftwareModuleType getSmType() {
return smType;
}
- /**
- * @return the key
- */
public DistributionSetTypeElementCompositeKey getKey() {
return key;
}
+ @Override
+ public String toString() {
+ return "DistributionSetTypeElement [mandatory=" + mandatory + ", dsType=" + dsType + ", smType=" + smType + "]";
+ }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElementCompositeKey.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElementCompositeKey.java
index c819d4e52..2ee1aba0d 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElementCompositeKey.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElementCompositeKey.java
@@ -15,17 +15,9 @@ import javax.persistence.Embeddable;
/**
* Composite key for {@link DistributionSetTypeElement}.
- *
- *
- *
- *
*/
@Embeddable
public class DistributionSetTypeElementCompositeKey implements Serializable {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
@Column(name = "distribution_set_type", nullable = false)
@@ -54,34 +46,19 @@ public class DistributionSetTypeElementCompositeKey implements Serializable {
this.smType = smType.getId();
}
- /**
- * @return the dsType
- */
public Long getDsType() {
return dsType;
}
- /**
- * @param dsType
- * the dsType to set
- */
public void setDsType(final Long dsType) {
this.dsType = dsType;
}
- /**
- * @return the smType
- */
public Long getSmType() {
return smType;
}
- /**
- * @param smType
- * the smType to set
- */
public void setSmType(final Long smType) {
this.smType = smType;
}
-
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DsMetadataCompositeKey.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DsMetadataCompositeKey.java
index f26a66ab9..adc37d65a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DsMetadataCompositeKey.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DsMetadataCompositeKey.java
@@ -13,24 +13,17 @@ import java.io.Serializable;
/**
* The DistributionSet Metadata composite key which contains the meta data key
* and the ID of the DistributionSet itself.
- *
- *
*
*/
public final class DsMetadataCompositeKey implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private String key;
private Long distributionSet;
- /**
- *
- */
public DsMetadataCompositeKey() {
+ // Default constructor for JPA.
}
/**
@@ -44,55 +37,31 @@ public final class DsMetadataCompositeKey implements Serializable {
this.key = key;
}
- /**
- * @return the key
- */
public String getKey() {
return key;
}
- /**
- * @param key
- * the key to set
- */
public void setKey(final String key) {
this.key = key;
}
- /**
- * @return the distributionSet
- */
public Long getDistributionSet() {
return distributionSet;
}
- /**
- * @param distributionSet
- * the distributionSet to set
- */
public void setDistributionSet(final Long distributionSet) {
this.distributionSet = distributionSet;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@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());
+ result = prime * result + (distributionSet == null ? 0 : distributionSet.hashCode());
+ result = prime * result + (key == null ? 0 : key.hashCode());
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
// code
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java
index 35e0c4e99..898c685a5 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java
@@ -22,12 +22,9 @@ import javax.persistence.Table;
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.
*
- *
- *
- *
*/
@Table(name = "sp_external_artifact", indexes = {
@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;
@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;
@Column(name = "url_suffix", length = 512)
@@ -44,7 +41,7 @@ public class ExternalArtifact extends Artifact {
// CascadeType.PERSIST as we register ourself at the BSM
@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;
/**
@@ -84,18 +81,11 @@ public class ExternalArtifact extends Artifact {
return softwareModule;
}
- /**
- * @param softwareModule
- * the softwareModule to set
- */
public final void setSoftwareModule(final SoftwareModule softwareModule) {
this.softwareModule = softwareModule;
this.softwareModule.addArtifact(this);
}
- /**
- * @return the externalArtifactProvider
- */
public ExternalArtifactProvider getExternalArtifactProvider() {
return externalArtifactProvider;
}
@@ -104,17 +94,10 @@ public class ExternalArtifact extends Artifact {
return new StringBuilder().append(externalArtifactProvider.getBasePath()).append(urlSuffix).toString();
}
- /**
- * @return the urlSuffix
- */
public String getUrlSuffix() {
return urlSuffix;
}
- /**
- * @param externalArtifactProvider
- * the externalArtifactProvider to set
- */
public void setExternalArtifactProvider(final ExternalArtifactProvider externalArtifactProvider) {
this.externalArtifactProvider = externalArtifactProvider;
}
@@ -127,11 +110,6 @@ public class ExternalArtifact extends Artifact {
this.urlSuffix = urlSuffix;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() { // NOSONAR - as this is generated
final int prime = 31;
@@ -140,16 +118,8 @@ public class ExternalArtifact extends Artifact {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java
index 56d92c8e1..d52e60e46 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java
@@ -15,11 +15,8 @@ import javax.persistence.Table;
/**
* External repositories for artifact storage. The SP server provides URLs for
- * the targets to download rom these external ressources but does not access
- * thenm itself.
- *
- *
- *
+ * the targets to download from these external resources but does not access
+ * them itself.
*
*/
@Table(name = "sp_external_provider", indexes = {
@@ -60,41 +57,22 @@ public class ExternalArtifactProvider extends NamedEntity {
basePath = "";
}
- /**
- * @return the basePath
- */
public String getBasePath() {
return basePath;
}
- /**
- * @return the defaultSuffix
- */
public String getDefaultSuffix() {
return defaultSuffix;
}
- /**
- * @param basePath
- * the basePath to set
- */
public void setBasePath(final String basePath) {
this.basePath = basePath;
}
- /**
- * @param defaultSuffix
- * the defaultSuffix to set
- */
public void setDefaultSuffix(final String defaultSuffix) {
this.defaultSuffix = defaultSuffix;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() { // NOSONAR - as this is generated
final int prime = 31;
@@ -103,16 +81,8 @@ public class ExternalArtifactProvider extends NamedEntity {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java
index baa4ee1f0..8afcdc168 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java
@@ -46,7 +46,7 @@ public class LocalArtifact extends Artifact {
private String filename;
@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;
/**
@@ -73,11 +73,6 @@ public class LocalArtifact extends Artifact {
this.filename = filename;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() { // NOSONAR - as this is generated
final int prime = 31;
@@ -86,16 +81,8 @@ public class LocalArtifact extends Artifact {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
@@ -106,33 +93,20 @@ public class LocalArtifact extends Artifact {
return true;
}
- /**
- * @return the softwareModule
- */
@Override
public SoftwareModule getSoftwareModule() {
return softwareModule;
}
- /**
- * @param softwareModule
- * the softwareModule to set
- */
public final void setSoftwareModule(final SoftwareModule softwareModule) {
this.softwareModule = softwareModule;
this.softwareModule.addArtifact(this);
}
- /**
- * @return the gridFsFileName
- */
public String getGridFsFileName() {
return gridFsFileName;
}
- /**
- * @return the filename
- */
public String getFilename() {
return filename;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java
index 30446a0bf..d055c113e 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java
@@ -12,14 +12,8 @@ import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
/**
- * {@link TenantAwareBaseEntity} extension for all entities that are named in addition to
- * their technical ID.
- *
- *
- *
- *
- *
- *
+ * {@link TenantAwareBaseEntity} extension for all entities that are named in
+ * addition to their technical ID.
*/
@MappedSuperclass
public abstract class NamedEntity extends TenantAwareBaseEntity {
@@ -40,7 +34,7 @@ public abstract class NamedEntity extends TenantAwareBaseEntity {
/**
* Parameterized constructor.
- *
+ *
* @param name
* of the {@link NamedEntity}
* @param description
@@ -67,4 +61,23 @@ public abstract class NamedEntity extends TenantAwareBaseEntity {
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;
+ }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java
index 77819ed46..2b126c72f 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java
@@ -14,11 +14,6 @@ import javax.persistence.MappedSuperclass;
/**
* Extension for {@link NamedEntity} that are versioned.
*
- *
- *
- *
- *
- *
*/
@MappedSuperclass
public abstract class NamedVersionedEntity extends NamedEntity {
@@ -29,7 +24,7 @@ public abstract class NamedVersionedEntity extends NamedEntity {
/**
* parameterized constructor.
- *
+ *
* @param name
* of the entity
* @param version
@@ -53,4 +48,24 @@ public abstract class NamedVersionedEntity extends NamedEntity {
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;
+ }
+
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java
index 83e541ed5..a596d10a9 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java
@@ -36,20 +36,20 @@ import org.eclipse.hawkbit.repository.model.Action.ActionType;
@Entity
@Table(name = "sp_rollout", indexes = {
@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 {
private static final long serialVersionUID = 1L;
@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 rolloutGroups;
@Column(name = "target_filter", length = 1024, nullable = false)
private String targetFilterQuery;
@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;
@Column(name = "status")
@@ -79,159 +79,86 @@ public class Rollout extends NamedEntity {
@Transient
private transient TotalTargetCountStatus totalTargetCountStatus;
- /**
- * @return the distributionSet
- */
public DistributionSet getDistributionSet() {
return distributionSet;
}
- /**
- * @param distributionSet
- * the distributionSet to set
- */
public void setDistributionSet(final DistributionSet distributionSet) {
this.distributionSet = distributionSet;
}
- /**
- * @return the rolloutGroups
- */
public List getRolloutGroups() {
return rolloutGroups;
}
- /**
- * @param rolloutGroups
- * the rolloutGroups to set
- */
public void setRolloutGroups(final List rolloutGroups) {
this.rolloutGroups = rolloutGroups;
}
- /**
- * @return the targetFilterQuery
- */
public String getTargetFilterQuery() {
return targetFilterQuery;
}
- /**
- * @param targetFilterQuery
- * the targetFilterQuery to set
- */
public void setTargetFilterQuery(final String targetFilterQuery) {
this.targetFilterQuery = targetFilterQuery;
}
- /**
- * @return the status
- */
public RolloutStatus getStatus() {
return status;
}
- /**
- * @param status
- * the status to set
- */
public void setStatus(final RolloutStatus status) {
this.status = status;
}
- /**
- * @return the lastCheck
- */
public long getLastCheck() {
return lastCheck;
}
- /**
- * @param lastCheck
- * the lastCheck to set
- */
public void setLastCheck(final long lastCheck) {
this.lastCheck = lastCheck;
}
- /**
- * @return the actionType
- */
public ActionType getActionType() {
return actionType;
}
- /**
- * @param actionType
- * the actionType to set
- */
public void setActionType(final ActionType actionType) {
this.actionType = actionType;
}
- /**
- * @return the forcedTime
- */
public long getForcedTime() {
return forcedTime;
}
- /**
- * @param forcedTime
- * the forcedTime to set
- */
public void setForcedTime(final long forcedTime) {
this.forcedTime = forcedTime;
}
- /**
- * @return the totalTargets
- */
public long getTotalTargets() {
return totalTargets;
}
- /**
- * @param totalTargets
- * the totalTargets to set
- */
public void setTotalTargets(final long totalTargets) {
this.totalTargets = totalTargets;
}
- /**
- * @return the rolloutGroupsTotal
- */
public int getRolloutGroupsTotal() {
return rolloutGroupsTotal;
}
- /**
- * @param rolloutGroupsTotal
- * the rolloutGroupsTotal to set
- */
public void setRolloutGroupsTotal(final int rolloutGroupsTotal) {
this.rolloutGroupsTotal = rolloutGroupsTotal;
}
- /**
- * @return the rolloutGroupsCreated
- */
public int getRolloutGroupsCreated() {
return rolloutGroupsCreated;
}
- /**
- * @param rolloutGroupsCreated
- * the rolloutGroupsCreated to set
- */
public void setRolloutGroupsCreated(final int rolloutGroupsCreated) {
this.rolloutGroupsCreated = rolloutGroupsCreated;
}
- /**
- * @return the totalTargetCountStatus
- */
public TotalTargetCountStatus getTotalTargetCountStatus() {
if (totalTargetCountStatus == null) {
totalTargetCountStatus = new TotalTargetCountStatus(totalTargets);
@@ -239,10 +166,6 @@ public class Rollout extends NamedEntity {
return totalTargetCountStatus;
}
- /**
- * @param totalTargetCountStatus
- * the totalTargetCountStatus to set
- */
public void setTotalTargetCountStatus(final TotalTargetCountStatus totalTargetCountStatus) {
this.totalTargetCountStatus = totalTargetCountStatus;
}
@@ -256,7 +179,7 @@ public class Rollout extends NamedEntity {
/**
*
- * @author Michael Hirsch
+ * State machine for rollout.
*
*/
public enum RolloutStatus {
@@ -308,4 +231,24 @@ public class Rollout extends NamedEntity {
*/
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;
+ }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java
index dcb95b254..97191b4f1 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java
@@ -34,13 +34,13 @@ import javax.persistence.UniqueConstraint;
@Entity
@Table(name = "sp_rolloutgroup", indexes = {
@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 {
private static final long serialVersionUID = 1L;
@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;
@Column(name = "status")
@@ -210,8 +210,7 @@ public class RolloutGroup extends NamedEntity {
}
/**
- *
- * @author Michael Hirsch
+ * Rollout goup state machine.
*
*/
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;
+ }
+
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroupId.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroupId.java
index 41850424b..88226142a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroupId.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroupId.java
@@ -12,14 +12,9 @@ import java.io.Serializable;
/**
* Combined unique key of the table {@link RolloutTargetGroup}.
- *
- * @author Michael Hirsch
*
*/
public class RolloutTargetGroupId implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private Long rolloutGroup;
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java
index 49e73f749..8b58c5e3b 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java
@@ -33,17 +33,12 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
/**
* 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
@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_02", columnList = "tenant,deleted,module_type"),
@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;
@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;
@ManyToMany(mappedBy = "modules", targetEntity = DistributionSet.class, fetch = FetchType.LAZY)
@@ -213,17 +208,10 @@ public class SoftwareModule extends NamedVersionedEntity {
return type;
}
- /**
- * @return the deleted
- */
public boolean isDeleted() {
return deleted;
}
- /**
- * @param deleted
- * the deleted to set
- */
public void setDeleted(final boolean 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 getMetadata() {
- return metadata;
+ return Collections.unmodifiableList(metadata);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
- return "SoftwareModule [type=" + type + ", deleted=" + deleted + ", getVersion()=" + getVersion()
- + ", getOptLockRevision()=" + getOptLockRevision() + ", getId()=" + getId() + ", getType()="
- + getType().getName() + "]";
+ return "SoftwareModule [deleted=" + deleted + ", name=" + getName() + ", version=" + getVersion()
+ + ", revision=" + getOptLockRevision() + ", Id=" + getId() + ", type=" + getType().getName() + "]";
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() { // NOSONAR - as this is generated
final int prime = 31;
@@ -264,16 +241,8 @@ public class SoftwareModule extends NamedVersionedEntity {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleIdName.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleIdName.java
index 8658de3c8..c59d42c5f 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleIdName.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleIdName.java
@@ -13,8 +13,6 @@ import java.io.Serializable;
/**
* To hold software module name and Id.
*
- *
- *
*/
public class SoftwareModuleIdName implements Serializable {
@@ -35,25 +33,14 @@ public class SoftwareModuleIdName implements Serializable {
this.name = name;
}
- /**
- * @return the id
- */
public Long getId() {
return id;
}
- /**
- * @return the name
- */
public String getName() {
return name;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {// NOSONAR - as this is generated
final int prime = 31;
@@ -62,11 +49,6 @@ public class SoftwareModuleIdName implements Serializable {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) {// NOSONAR - as this is generated
if (this == obj) {
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleMetadata.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleMetadata.java
index dfc1ecfa7..c7af1f2ae 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleMetadata.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleMetadata.java
@@ -24,18 +24,11 @@ import javax.persistence.Table;
/**
* Metadata for {@link SoftwareModule}.
*
- *
- *
- *
*/
@IdClass(SwMetadataCompositeKey.class)
@Entity
@Table(name = "sp_sw_metadata")
public class SoftwareModuleMetadata implements Serializable {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
@Id
@@ -50,18 +43,21 @@ public class SoftwareModuleMetadata implements Serializable {
@JoinColumn(name = "sw_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
private SoftwareModule softwareModule;
+ /**
+ * Default constructor for JPA.
+ */
public SoftwareModuleMetadata() {
-
+ // default constructor for JPA.
}
/**
* Standard constructor.
*
* @param key
- * of the metadata element
+ * of the meta data element
* @param softwareModule
* @param value
- * of the metadata element
+ * of the meta data element
*/
public SoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
this.key = key;
@@ -69,56 +65,75 @@ public class SoftwareModuleMetadata implements Serializable {
this.value = value;
}
- /**
- * @return the id
- */
public SwMetadataCompositeKey getId() {
return new SwMetadataCompositeKey(softwareModule, key);
}
- /**
- * @return the value
- */
public String getValue() {
return value;
}
- /**
- * @param value
- * the value to set
- */
public void setValue(final String value) {
this.value = value;
}
- /**
- * @return the softwareModule
- */
public SoftwareModule getSoftwareModule() {
return softwareModule;
}
- /**
- * @param softwareModule
- * the softwareModule to set
- */
public void setSoftwareModule(final SoftwareModule softwareModule) {
this.softwareModule = softwareModule;
}
- /**
- * @return the key
- */
public String getKey() {
return key;
}
- /**
- * @param key
- * the key to set
- */
public void setKey(final String 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;
+ }
+
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java
index 49427b9ea..59246d92e 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java
@@ -17,9 +17,6 @@ import javax.persistence.UniqueConstraint;
/**
* Type of a software modules.
*
- *
- *
- *
*/
@Entity
@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 = { "name", "tenant" }, name = "uk_smt_name") })
public class SoftwareModuleType extends NamedEntity {
- /**
- *
- */
private static final long serialVersionUID = 1L;
@Column(name = "type_key", nullable = false, length = 64)
@@ -92,48 +86,26 @@ public class SoftwareModuleType extends NamedEntity {
super();
}
- /**
- * @return the key
- */
public String getKey() {
return key;
}
- /**
- * @return the max
- */
public int getMaxAssignments() {
return maxAssignments;
}
- /**
- * @return the deleted
- */
public boolean isDeleted() {
return deleted;
}
- /**
- * @param deleted
- * the deleted to set
- */
public void setDeleted(final boolean deleted) {
this.deleted = deleted;
}
- /**
- *
- * @return the software type color
- */
public String getColour() {
return colour;
}
- /**
- *
- * @param colour
- * the col
- */
public void setColour(final String colour) {
this.colour = colour;
}
@@ -143,4 +115,23 @@ public class SoftwareModuleType extends NamedEntity {
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;
+ }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SwMetadataCompositeKey.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SwMetadataCompositeKey.java
index 2518e4b1b..90b3779a1 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SwMetadataCompositeKey.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SwMetadataCompositeKey.java
@@ -11,16 +11,10 @@ package org.eclipse.hawkbit.repository.model;
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.
- *
- *
- *
*/
public final class SwMetadataCompositeKey implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private String key;
@@ -28,9 +22,10 @@ public final class SwMetadataCompositeKey implements Serializable {
private Long softwareModule;
/**
- *
- */
+ * Default constructor for JPA.
+ */
public SwMetadataCompositeKey() {
+ // Default constructor for JPA.
}
/**
@@ -74,25 +69,15 @@ public final class SwMetadataCompositeKey implements Serializable {
this.softwareModule = softwareModule;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@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());
+ result = prime * result + (key == null ? 0 : key.hashCode());
+ result = prime * result + (softwareModule == null ? 0 : softwareModule.hashCode());
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
// code
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java
index c03a02f3e..8d5f5b832 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java
@@ -14,14 +14,9 @@ import javax.persistence.MappedSuperclass;
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.
*
- *
- *
- *
- *
- *
*/
@MappedSuperclass
public abstract class Tag extends NamedEntity implements Identifiable {
@@ -57,14 +52,28 @@ public abstract class Tag extends NamedEntity implements Identifiable {
this.colour = colour;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
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;
+ }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java
index 07a97ebcf..f9e29118f 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java
@@ -56,11 +56,6 @@ import org.springframework.data.domain.Persistable;
* {@link TargetStatus#REGISTERED}, i.e. a target {@link DistributionSet} .
*
*
- *
- *
- *
- *
- *
*/
@Entity
@Table(name = "sp_target", indexes = {
@@ -117,7 +112,7 @@ public class Target extends NamedEntity implements Persistable {
/**
* Constructor.
- *
+ *
* @param controllerId
* controller ID of the {@link Target}
*/
@@ -136,15 +131,18 @@ public class Target extends NamedEntity implements Persistable {
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
public boolean equals(final Object obj) {// NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
if (obj == null) {
return false;
}
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof Target)) {
return false;
}
final Target other = (Target) obj;
@@ -182,25 +180,14 @@ public class Target extends NamedEntity implements Persistable {
this.assignedDistributionSet = assignedDistributionSet;
}
- /**
- * @param controllerId
- * the controllerId to set
- */
public void setControllerId(final String controllerId) {
this.controllerId = controllerId;
}
- /**
- * @param tags
- * the tags to set
- */
public void setTags(final Set tags) {
this.tags = tags;
}
- /**
- * @return the actions
- */
public List getActions() {
return actions;
}
@@ -209,11 +196,6 @@ public class Target extends NamedEntity implements Persistable {
return new TargetIdName(getId(), getControllerId(), getName());
}
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Persistable#isNew()
- */
@Override
@Transient
public boolean isNew() {
@@ -261,11 +243,6 @@ public class Target extends NamedEntity implements Persistable {
this.securityToken = securityToken;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return "Target [controllerId=" + controllerId + ", getId()=" + getId() + "]";
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java
index f14fc26e2..c4e6fb1fe 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java
@@ -15,18 +15,14 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
/**
- *
+ * Stored target filter.
*
*/
@Entity
@Table(name = "sp_target_filter_query", indexes = {
@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 {
- /**
- *
- *
- */
private static final long serialVersionUID = 7493966984413479089L;
@Column(name = "name", length = 64)
@@ -36,8 +32,7 @@ public class TargetFilterQuery extends TenantAwareBaseEntity {
private String query;
public TargetFilterQuery() {
- name = null;
- query = null;
+ // Default constructor for JPA.
}
public TargetFilterQuery(final String name, final String query) {
@@ -45,63 +40,39 @@ public class TargetFilterQuery extends TenantAwareBaseEntity {
this.query = query;
}
- /**
- * @return the name
- */
public String getName() {
return name;
}
- /**
- * @param name
- * the name to set
- */
public void setName(final String name) {
this.name = name;
}
- /**
- * @return the query
- */
public String getQuery() {
return query;
}
- /**
- * @param query
- * the query to set
- */
public void setQuery(final String query) {
this.query = query;
}
@Override
- public boolean equals(final Object obj) {// NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- 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;
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + this.getClass().getName().hashCode();
+ return result;
}
@Override
- public int hashCode() { // NOSONAR - as this is generated
- final int prime = 31;
- int result = 1;
- result = prime * result + (name == null ? 0 : name.hashCode());
- return result;
+ public boolean equals(final Object obj) {
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof TargetFilterQuery)) {
+ return false;
+ }
+
+ return true;
}
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetIdName.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetIdName.java
index f7a63b775..26a74e9bb 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetIdName.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetIdName.java
@@ -13,19 +13,12 @@ import java.io.Serializable;
/**
* ID class of the {@link Target} which contains the
* {@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
- * resolve for e.g. the UI the name of the target, this is very costly
+ * object. Often it's necessary to remember the IDs of the {@link Target} and
+ * 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}
* is already in memory available.
- *
- *
- *
- *
*/
public class TargetIdName implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private final long targetId;
@@ -46,61 +39,34 @@ public class TargetIdName implements Serializable {
this.name = name;
}
- /**
- * @return the controller id
- */
public String getControllerId() {
return controllerId;
}
- /**
- * @return the name
- */
public String getName() {
return name;
}
- /**
- * @param id
- * the id to set
- */
public void setControllerId(final String id) {
- this.controllerId = id;
+ controllerId = id;
}
- /**
- * @param name
- * the name to set
- */
public void setName(final String name) {
this.name = name;
}
- /**
- * @return the targetId
- */
public long getTargetId() {
return targetId;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + (int) (targetId ^ (targetId >>> 32));
+ result = prime * result + (int) (targetId ^ targetId >>> 32);
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) {
if (this == obj) {
@@ -119,11 +85,6 @@ public class TargetIdName implements Serializable {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java
index 09d9fed28..47f52579a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java
@@ -54,19 +54,11 @@ import org.springframework.data.domain.Persistable;
* modifying the {@link Target} itself when a controller reports it's
* {@link #lastTargetQuery} for example.
*
- *
- *
- *
*/
@Table(name = "sp_target_info", indexes = {
@Index(name = "sp_idx_target_info_02", columnList = "target_id,update_status") })
@Entity
-// @DynamicUpdate
public class TargetInfo implements Persistable, Serializable {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(TargetInfo.class);
@@ -81,9 +73,6 @@ public class TargetInfo implements Persistable, Serializable {
@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"))
@MapsId
- // use deprecated annotation until HHH-8862 is fixed
- // @SuppressWarnings( "deprecation" )
- // @org.hibernate.annotations.ForeignKey( name = "fk_targ_stat_targ" )
private Target target;
@Column(name = "address", length = 512)
@@ -111,9 +100,7 @@ public class TargetInfo implements Persistable, Serializable {
@MapKeyColumn(name = "attribute_key", nullable = false, length = 32)
@CollectionTable(name = "sp_target_attributes", joinColumns = {
@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 controllerAttributes = Collections.synchronizedMap(new HashMap());
// set default request controller attributes to true, because we want to
@@ -124,7 +111,7 @@ public class TargetInfo implements Persistable, Serializable {
/**
* Constructor for {@link TargetStatus}.
- *
+ *
* @param target
* related to this status.
*/
@@ -138,21 +125,11 @@ public class TargetInfo implements Persistable, Serializable {
targetId = null;
}
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Persistable#getId()
- */
@Override
public Long getId() {
return targetId;
}
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Persistable#isNew()
- */
@Override
@Transient
public boolean isNew() {
@@ -198,114 +175,62 @@ public class TargetInfo implements Persistable, Serializable {
this.address = address;
}
- /**
- * @return the targetId
- */
public Long getTargetId() {
return targetId;
}
- /**
- * @param targetId
- * the targetId to set
- */
public void setTargetId(final Long targetId) {
this.targetId = targetId;
}
- /**
- * @return the target
- */
public Target getTarget() {
return target;
}
- /**
- * @param target
- * the target to set
- */
public void setTarget(final Target target) {
this.target = target;
}
- /**
- * @return the lastTargetQuery
- */
public Long getLastTargetQuery() {
return lastTargetQuery;
}
- /**
- * @param lastTargetQuery
- * the lastTargetQuery to set
- */
public void setLastTargetQuery(final Long lastTargetQuery) {
this.lastTargetQuery = lastTargetQuery;
}
- /**
- * @param requestControllerAttributes
- * the requestControllerAttributes to set
- */
public void setRequestControllerAttributes(final boolean requestControllerAttributes) {
this.requestControllerAttributes = requestControllerAttributes;
}
- /**
- * @return the controllerAttributes
- */
public Map getControllerAttributes() {
return controllerAttributes;
}
- /**
- * @return the requestControllerAttributes
- */
public boolean isRequestControllerAttributes() {
return requestControllerAttributes;
}
- /**
- * @return the installationDate
- */
public Long getInstallationDate() {
return installationDate;
}
- /**
- * @param installationDate
- * the installationDate to set
- */
public void setInstallationDate(final Long installationDate) {
this.installationDate = installationDate;
}
- /**
- * @return the updateStatus
- */
public TargetUpdateStatus getUpdateStatus() {
return updateStatus;
}
- /**
- * @param updateStatus
- * the updateStatus to set
- */
public void setUpdateStatus(final TargetUpdateStatus updateStatus) {
this.updateStatus = updateStatus;
}
- /**
- * @return the installedDistributionSet
- */
public DistributionSet getInstalledDistributionSet() {
return installedDistributionSet;
}
- /**
- * @param installedDistributionSet
- * the installedDistributionSet to set
- */
public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) {
this.installedDistributionSet = installedDistributionSet;
}
@@ -338,8 +263,6 @@ public class TargetInfo implements Persistable, Serializable {
* 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
* overdue poll time.
- *
- *
*
*/
public static final class PollStatus {
@@ -359,7 +282,7 @@ public class TargetInfo implements Persistable, Serializable {
/**
* calculates if the target poll time is overdue and the target has not
* been polled in the configured poll time interval.
- *
+ *
* @return {@code true} if the current time is after the poll time
* overdue date otherwise {@code false}.
*/
@@ -386,15 +309,48 @@ public class TargetInfo implements Persistable, Serializable {
return currentDate;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return "PollTime [lastPollDate=" + lastPollDate + ", nextPollDate=" + nextPollDate + ", overdueDate="
+ 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;
+ }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTag.java
index 781bf9d16..5a5a310d0 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTag.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTag.java
@@ -21,16 +21,11 @@ import javax.persistence.UniqueConstraint;
* A {@link TargetTag} is used to describe Target attributes and use them also
* for filtering the target list.
*
- *
- *
- *
- *
- *
*/
@Entity
@Table(name = "sp_target_tag", indexes = {
@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 {
private static final long serialVersionUID = 1L;
@@ -65,18 +60,10 @@ public class TargetTag extends Tag {
super();
}
- /**
- * @return the assignedToTargets
- */
public List getAssignedToTargets() {
return assignedToTargets;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
@@ -85,16 +72,8 @@ public class TargetTag extends Tag {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
if (!super.equals(obj)) {
return false;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssigmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssignmentResult.java
similarity index 82%
rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssigmentResult.java
rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssignmentResult.java
index b12b80d58..789e6adf2 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssigmentResult.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssignmentResult.java
@@ -11,13 +11,10 @@ package org.eclipse.hawkbit.repository.model;
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 List assignedTargets;
@@ -40,7 +37,7 @@ public class TargetTagAssigmentResult extends AssignmentResult {
* @param targetTag
* 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 assignedTargets, final List unassignedTargets, final TargetTag targetTag) {
super(assigned, alreadyAssigned);
this.unassigned = unassigned;
@@ -49,23 +46,14 @@ public class TargetTagAssigmentResult extends AssignmentResult {
this.targetTag = targetTag;
}
- /**
- * @return the unassigned
- */
public int getUnassigned() {
return unassigned;
}
- /**
- * @return the assignedTargets
- */
public List getAssignedTargets() {
return assignedTargets;
}
- /**
- * @return the unassignedTargets
- */
public List getUnassignedTargets() {
return unassignedTargets;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetUpdateStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetUpdateStatus.java
index cecbf8339..7721dabda 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetUpdateStatus.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetUpdateStatus.java
@@ -13,11 +13,6 @@ package org.eclipse.hawkbit.repository.model;
* status. A {@link Target} can have only one status. independent of the number
* of {@link UpdateAction}s that have to be applied.
*
- *
- *
- *
- *
- *
*/
public enum TargetUpdateStatus {
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java
index a75141658..ec09da3d5 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java
@@ -30,32 +30,18 @@ public class TargetWithActionStatus {
this.target = target;
}
- /**
- * @return the target
- */
public Target getTarget() {
return target;
}
- /**
- * @return the status
- */
public Status getStatus() {
return status;
}
- /**
- * @param target
- * the target to set
- */
public void setTarget(final Target target) {
this.target = target;
}
- /**
- * @param status
- * the status to set
- */
public void setStatus(final Status status) {
this.status = status;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java
index 82b7fa353..97d757fb5 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java
@@ -70,23 +70,36 @@ public abstract class TenantAwareBaseEntity extends BaseEntity {
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
- public int hashCode() { // NOSONAR - as this is generated
+ public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = prime * result + ((tenant == null) ? 0 : tenant.hashCode());
+ result = prime * result + (tenant == null ? 0 : tenant.hashCode());
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
- public boolean equals(final Object obj) { // NOSONAR - as this is generated
- if (this == obj) {
- return true;
- }
+ public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof TenantAwareBaseEntity)) {
return false;
}
final TenantAwareBaseEntity other = (TenantAwareBaseEntity) obj;
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java
index 972ea1ffe..efc82747a 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java
@@ -19,18 +19,11 @@ import javax.persistence.UniqueConstraint;
/**
* A JPA entity which stores the tenant specific configuration.
*
- *
- *
- *
*/
@Entity
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
"tenant" }, name = "uk_tenant_key"))
public class TenantConfiguration extends TenantAwareBaseEntity implements Serializable {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
@Column(name = "conf_key", length = 128)
@@ -89,44 +82,23 @@ public class TenantConfiguration extends TenantAwareBaseEntity implements Serial
this.value = value;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
- int result = 1;
- result = prime * result + ((key == null) ? 0 : key.hashCode());
+ int result = super.hashCode();
+ result = prime * result + this.getClass().getName().hashCode();
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
- public boolean equals(final Object obj) { // NOSONAR - as this is generated
- // code
- if (this == obj) {
- return true;
- }
- if (obj == null) {
+ public boolean equals(final Object obj) {
+ if (!super.equals(obj)) {
return false;
}
- if (getClass() != obj.getClass()) {
- return false;
- }
- final TenantConfiguration other = (TenantConfiguration) obj;
- if (key == null) {
- if (other.key != null) {
- return false;
- }
- } else if (!key.equals(other.key)) {
+ if (!(obj instanceof TenantConfiguration)) {
return false;
}
+
return true;
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantMetaData.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantMetaData.java
index 5b75bd0bd..a9572c21c 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantMetaData.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantMetaData.java
@@ -24,7 +24,7 @@ import javax.persistence.UniqueConstraint;
* 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
* through the {@link EntityManager} even before the actual tenant exists.
- *
+ *
* Entities owned by the tenant are based on {@link TenantAwareBaseEntity}.
*
*/
@@ -78,4 +78,23 @@ public class TenantMetaData extends BaseEntity {
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;
+ }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java
index 03f213fef..c2ed5f900 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java
@@ -139,14 +139,6 @@ public final class RSQLUtility {
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
public Predicate toPredicate(final Root root, final CriteriaQuery> query, final CriteriaBuilder cb) {
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java
index 4150229c6..b95f0b8e7 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java
@@ -11,13 +11,11 @@ package org.eclipse.hawkbit.repository.specifications;
import java.util.Collection;
import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.ListJoin;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
import javax.persistence.criteria.SetJoin;
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
- * Data JPQL Specifications
- *
- *
+ * Data JPQL Specifications.
*
*/
public final class DistributionSetSpecification {
@@ -53,16 +49,8 @@ public final class DistributionSetSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification isDeleted(final Boolean isDeleted) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSet_.deleted), isDeleted);
- return predicate;
- }
- };
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(DistributionSet_.deleted), isDeleted);
- return spec;
}
/**
@@ -75,16 +63,8 @@ public final class DistributionSetSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification isCompleted(final Boolean isCompleted) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSet_.complete), isCompleted);
- return predicate;
- }
- };
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(DistributionSet_.complete), isCompleted);
- return spec;
}
/**
@@ -96,21 +76,15 @@ public final class DistributionSetSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification byId(final Long distid) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
+ return (targetRoot, query, cb) -> {
+ final Predicate predicate = cb.equal(targetRoot. get(DistributionSet_.id), distid);
+ targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT);
+ targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT);
+ targetRoot.fetch(DistributionSet_.type, JoinType.LEFT);
+ query.distinct(true);
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSet_.id), distid);
- targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT);
- targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT);
- targetRoot.fetch(DistributionSet_.type, JoinType.LEFT);
- query.distinct(true);
-
- return predicate;
- }
+ return predicate;
};
- return spec;
}
/**
@@ -122,20 +96,14 @@ public final class DistributionSetSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification byIds(final Collection distids) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
-
- final Predicate predicate = targetRoot. get(DistributionSet_.id).in(distids);
- targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT);
- targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT);
- targetRoot.fetch(DistributionSet_.type, JoinType.LEFT);
- query.distinct(true);
- return predicate;
- }
+ return (targetRoot, query, cb) -> {
+ final Predicate predicate = targetRoot. get(DistributionSet_.id).in(distids);
+ 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;
}
/**
@@ -147,21 +115,10 @@ public final class DistributionSetSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification likeNameOrDescriptionOrVersion(final String subString) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb
- .or(cb.like(cb.lower(targetRoot. get(DistributionSet_.name)), subString.toLowerCase()),
- cb.like(cb.lower(targetRoot. get(DistributionSet_.version)),
- subString.toLowerCase()),
- cb.like(cb.lower(targetRoot. get(DistributionSet_.description)),
- subString.toLowerCase()));
- return predicate;
- }
- };
-
- return spec;
+ return (targetRoot, query, cb) -> cb.or(
+ cb.like(cb.lower(targetRoot. get(DistributionSet_.name)), subString.toLowerCase()),
+ cb.like(cb.lower(targetRoot. get(DistributionSet_.version)), subString.toLowerCase()),
+ cb.like(cb.lower(targetRoot. get(DistributionSet_.description)), subString.toLowerCase()));
}
/**
@@ -176,19 +133,13 @@ public final class DistributionSetSpecification {
*/
public static Specification hasTags(final Collection tagNames,
final Boolean selectDSWithNoTag) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final SetJoin tags = targetRoot.join(DistributionSet_.tags,
- JoinType.LEFT);
- final Predicate predicate = getPredicate(tags, tagNames, selectDSWithNoTag, cb);
- query.distinct(true);
- return predicate;
- }
+ return (targetRoot, query, cb) -> {
+ final SetJoin tags = targetRoot.join(DistributionSet_.tags,
+ JoinType.LEFT);
+ final Predicate predicate = getPredicate(tags, tagNames, selectDSWithNoTag, cb);
+ query.distinct(true);
+ return predicate;
};
-
- return spec;
}
private static Predicate getPredicate(final SetJoin tags,
@@ -218,20 +169,10 @@ public final class DistributionSetSpecification {
*/
public static Specification equalsNameAndVersionIgnoreCase(final String name,
final String version) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.and(
- // formatter:off
- cb.equal(cb.lower(targetRoot. get(DistributionSet_.name)), name.toLowerCase()),
- cb.equal(cb.lower(targetRoot. get(DistributionSet_.version)), version.toLowerCase()));
- // formatter:on
- return predicate;
- }
- };
+ return (targetRoot, query, cb) -> cb.and(
+ cb.equal(cb.lower(targetRoot. get(DistributionSet_.name)), name.toLowerCase()),
+ cb.equal(cb.lower(targetRoot. get(DistributionSet_.version)), version.toLowerCase()));
- return spec;
}
/**
@@ -243,16 +184,8 @@ public final class DistributionSetSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification byType(final DistributionSetType type) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSet_.type), type);
- return predicate;
- }
- };
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(DistributionSet_.type), type);
- return spec;
}
/**
@@ -263,18 +196,12 @@ public final class DistributionSetSpecification {
* installed to the given targetId
*/
public static Specification installedTarget(final String installedTargetId) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root dsRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final ListJoin installedTargetJoin = dsRoot
- .join(DistributionSet_.installedAtTargets, JoinType.INNER);
- final Join targetJoin = installedTargetJoin.join(TargetInfo_.target);
- return cb.equal(targetJoin.get(Target_.controllerId), installedTargetId);
- }
+ return (dsRoot, query, cb) -> {
+ final ListJoin installedTargetJoin = dsRoot
+ .join(DistributionSet_.installedAtTargets, JoinType.INNER);
+ final Join 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
*/
public static Specification assignedTarget(final String assignedTargetId) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root dsRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final ListJoin assignedTargetJoin = dsRoot
- .join(DistributionSet_.assignedToTargets, JoinType.INNER);
- return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId);
- }
+ return (dsRoot, query, cb) -> {
+ final ListJoin assignedTargetJoin = dsRoot.join(DistributionSet_.assignedToTargets,
+ JoinType.INNER);
+ return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId);
};
- return spec;
}
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetTypeSpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetTypeSpecification.java
index 1caa5ef59..13776deb0 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetTypeSpecification.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetTypeSpecification.java
@@ -8,22 +8,14 @@
*/
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.DistributionSetType;
import org.eclipse.hawkbit.repository.model.DistributionSetType_;
import org.springframework.data.jpa.domain.Specification;
/**
- *
- *
- *
- *
- *
+ * Specifications class for {@link DistributionSetType}s. The class provides
+ * Spring Data JPQL Specifications.
*/
public final class DistributionSetTypeSpecification {
private DistributionSetTypeSpecification() {
@@ -40,16 +32,7 @@ public final class DistributionSetTypeSpecification {
* @return the {@link DistributionSetType} {@link Specification}
*/
public static Specification isDeleted(final Boolean isDeleted) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSetType_.deleted), isDeleted);
- return predicate;
- }
- };
-
- return spec;
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(DistributionSetType_.deleted), isDeleted);
}
/**
@@ -62,16 +45,7 @@ public final class DistributionSetTypeSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification byId(final Long distid) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
-
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSetType_.id), distid);
- return predicate;
- }
- };
- return spec;
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(DistributionSetType_.id), distid);
}
/**
@@ -84,16 +58,7 @@ public final class DistributionSetTypeSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification byName(final String name) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
-
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSetType_.name), name);
- return predicate;
- }
- };
- return spec;
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(DistributionSetType_.name), name);
}
/**
@@ -106,16 +71,7 @@ public final class DistributionSetTypeSpecification {
* @return the {@link DistributionSet} {@link Specification}
*/
public static Specification byKey(final String key) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
-
- final Predicate predicate = cb.equal(targetRoot. get(DistributionSetType_.key), key);
- return predicate;
- }
- };
- return spec;
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(DistributionSetType_.key), key);
}
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/SoftwareModuleSpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/SoftwareModuleSpecification.java
index 2311f59f6..680f97778 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/SoftwareModuleSpecification.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/SoftwareModuleSpecification.java
@@ -8,10 +8,7 @@
*/
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.SoftwareModule;
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
* Data JPQL Specifications
*
- *
- *
*/
public final class SoftwareModuleSpecification {
private SoftwareModuleSpecification() {
@@ -39,38 +34,21 @@ public final class SoftwareModuleSpecification {
* @return the {@link SoftwareModule} {@link Specification}
*/
public static Specification byId(final Long moduleId) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
-
- final Predicate predicate = cb.equal(targetRoot. get(SoftwareModule_.id), moduleId);
- targetRoot.fetch(SoftwareModule_.type);
- return predicate;
- }
+ return (targetRoot, query, cb) -> {
+ final Predicate predicate = cb.equal(targetRoot. get(SoftwareModule_.id), moduleId);
+ targetRoot.fetch(SoftwareModule_.type);
+ return predicate;
};
- return spec;
}
/**
- * {@link Specification} for retrieving {@link SoftwareModule}s by its
- * DELETED attribute.
+ * {@link Specification} for retrieving {@link SoftwareModule}s where its
+ * 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}
*/
public static Specification isDeletedFalse() {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root swRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.equal(swRoot. get(SoftwareModule_.deleted), Boolean.FALSE);
- return predicate;
- }
- };
- return spec;
+ return (swRoot, query, cb) -> cb.equal(swRoot. get(SoftwareModule_.deleted), Boolean.FALSE);
}
/**
@@ -82,18 +60,9 @@ public final class SoftwareModuleSpecification {
* @return the {@link SoftwareModule} {@link Specification}
*/
public static Specification likeNameOrVersion(final String subString) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.or(
- cb.like(cb.lower(targetRoot. get(SoftwareModule_.name)), subString.toLowerCase()),
- cb.like(cb.lower(targetRoot. get(SoftwareModule_.version)), subString.toLowerCase()));
- return predicate;
- }
- };
-
- return spec;
+ return (targetRoot, query, cb) -> cb.or(
+ cb.like(cb.lower(targetRoot. get(SoftwareModule_.name)), subString.toLowerCase()),
+ cb.like(cb.lower(targetRoot. get(SoftwareModule_.version)), subString.toLowerCase()));
}
/**
@@ -105,16 +74,7 @@ public final class SoftwareModuleSpecification {
* @return the {@link SoftwareModule} {@link Specification}
*/
public static Specification equalType(final SoftwareModuleType type) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.equal(targetRoot. get(SoftwareModule_.type), type);
- return predicate;
- }
- };
-
- return spec;
+ return (targetRoot, query, cb) -> cb.equal(targetRoot. get(SoftwareModule_.type), type);
}
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetFilterQuerySpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetFilterQuerySpecification.java
index c92da7ed1..0b600c849 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetFilterQuerySpecification.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetFilterQuerySpecification.java
@@ -8,17 +8,13 @@
*/
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.springframework.data.jpa.domain.Specification;
/**
- *
+ * Specifications class for {@link TargetFilterQuery}s. The class provides
+ * Spring Data JPQL Specifications.
*
*/
public class TargetFilterQuerySpecification {
@@ -27,16 +23,9 @@ public class TargetFilterQuerySpecification {
}
public static Specification likeName(final String searchText) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetFilterQueryRoot,
- 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 (targetFilterQueryRoot, query, cb) -> {
+ final String searchTextToLower = searchText.toLowerCase();
+ return cb.like(cb.lower(targetFilterQueryRoot.get(TargetFilterQuery_.name)), searchTextToLower);
};
- return spec;
}
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java
index fb0e5740e..de894d3a3 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java
@@ -12,7 +12,6 @@ import java.util.Collection;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
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.
*
- *
- *
*/
public final class TargetSpecifications {
private TargetSpecifications() {
@@ -54,18 +51,12 @@ public final class TargetSpecifications {
* @return the {@link Target} {@link Specification}
*/
public static Specification byControllerIdWithStatusAndTagsInJoin(final Collection controllerIDs) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
- targetRoot.fetch(Target_.tags, JoinType.LEFT);
- query.distinct(true);
- return predicate;
- }
+ return (targetRoot, query, cb) -> {
+ final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
+ targetRoot.fetch(Target_.tags, JoinType.LEFT);
+ query.distinct(true);
+ return predicate;
};
-
- return spec;
}
/**
@@ -79,18 +70,12 @@ public final class TargetSpecifications {
*/
public static Specification byControllerIdWithStatusAndAssignedInJoin(
final Collection controllerIDs) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
+ return (targetRoot, query, cb) -> {
- final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
- targetRoot.fetch(Target_.assignedDistributionSet);
- return predicate;
- }
+ final Predicate predicate = targetRoot.get(Target_.controllerId).in(controllerIDs);
+ targetRoot.fetch(Target_.assignedDistributionSet);
+ return predicate;
};
-
- return spec;
}
/**
@@ -106,24 +91,18 @@ public final class TargetSpecifications {
*/
public static Specification hasTargetUpdateStatus(final Collection updateStatus,
final boolean fetch) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- if (!query.getResultType().isAssignableFrom(Long.class)) {
- if (fetch) {
- targetRoot.fetch(Target_.targetInfo);
- } else {
- targetRoot.join(Target_.targetInfo);
- }
- return targetRoot.get(Target_.targetInfo).get(TargetInfo_.updateStatus).in(updateStatus);
+ return (targetRoot, query, cb) -> {
+ if (!query.getResultType().isAssignableFrom(Long.class)) {
+ if (fetch) {
+ targetRoot.fetch(Target_.targetInfo);
+ } else {
+ targetRoot.join(Target_.targetInfo);
}
- final Join targetInfoJoin = targetRoot.join(Target_.targetInfo);
- return targetInfoJoin.get(TargetInfo_.updateStatus).in(updateStatus);
+ return targetRoot.get(Target_.targetInfo).get(TargetInfo_.updateStatus).in(updateStatus);
}
+ final Join 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}
*/
public static Specification likeNameOrDescriptionOrIp(final String searchText) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- 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 (targetRoot, query, cb) -> {
+ final String searchTextToLower = searchText.toLowerCase();
+ return cb.or(cb.like(cb.lower(targetRoot.get(Target_.name)), searchTextToLower),
+ cb.like(cb.lower(targetRoot.get(Target_.description)), searchTextToLower));
};
-
- return spec;
}
/**
@@ -158,21 +130,14 @@ public final class TargetSpecifications {
* @return the {@link Target} {@link Specification}
*/
public static Specification hasInstalledOrAssignedDistributionSet(@NotNull final Long distributionId) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Join targetInfoJoin = targetRoot.join(Target_.targetInfo);
- final Predicate predicate = cb.or(
- cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
- distributionId),
- cb.equal(targetRoot. get(Target_.assignedDistributionSet)
- .get(DistributionSet_.id), distributionId));
- return predicate;
- }
+ return (targetRoot, query, cb) -> {
+ final Join targetInfoJoin = targetRoot.join(Target_.targetInfo);
+ return cb.or(
+ cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
+ distributionId),
+ cb.equal(targetRoot. get(Target_.assignedDistributionSet).get(DistributionSet_.id),
+ distributionId));
};
-
- return spec;
}
/**
@@ -187,18 +152,11 @@ public final class TargetSpecifications {
*/
public static Specification hasControllerIdAndAssignedDistributionSetIdNot(final List tIDs,
@NotNull final Long distributionId) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = cb.and(targetRoot.get(Target_.controllerId).in(tIDs),
+ return (targetRoot, query, cb) -> cb
+ .and(targetRoot.get(Target_.controllerId).in(tIDs),
cb.or(cb.notEqual(targetRoot. get(Target_.assignedDistributionSet)
.get(DistributionSet_.id), distributionId),
- cb.isNull(targetRoot. get(Target_.assignedDistributionSet))));
- return predicate;
- }
- };
- return spec;
+ cb.isNull(targetRoot. get(Target_.assignedDistributionSet))));
}
/**
@@ -212,16 +170,11 @@ public final class TargetSpecifications {
* @return the {@link Target} {@link Specification}
*/
public static Specification hasTags(final String[] tagNames, final Boolean selectTargetWithNoTag) {
- final Specification spec = new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Predicate predicate = getPredicate(targetRoot, cb, selectTargetWithNoTag, tagNames);
- query.distinct(true);
- return predicate;
- }
+ return (targetRoot, query, cb) -> {
+ final Predicate predicate = getPredicate(targetRoot, cb, selectTargetWithNoTag, tagNames);
+ query.distinct(true);
+ return predicate;
};
- return spec;
}
private static Predicate getPredicate(final Root targetRoot, final CriteriaBuilder cb,
@@ -248,15 +201,9 @@ public final class TargetSpecifications {
* @return the {@link Target} {@link Specification}
*/
public static Specification hasAssignedDistributionSet(final Long distributionSetId) {
- return new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- return cb.equal(
- targetRoot. get(Target_.assignedDistributionSet).get(DistributionSet_.id),
- distributionSetId);
- }
- };
+ return (targetRoot, query, cb) -> cb.equal(
+ targetRoot. get(Target_.assignedDistributionSet).get(DistributionSet_.id),
+ distributionSetId);
}
/**
@@ -268,14 +215,10 @@ public final class TargetSpecifications {
* @return the {@link Target} {@link Specification}
*/
public static Specification hasInstalledDistributionSet(final Long distributionSetId) {
- return new Specification() {
- @Override
- public Predicate toPredicate(final Root targetRoot, final CriteriaQuery> query,
- final CriteriaBuilder cb) {
- final Join targetInfoJoin = targetRoot.join(Target_.targetInfo);
- return cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
- distributionSetId);
- }
+ return (targetRoot, query, cb) -> {
+ final Join targetInfoJoin = targetRoot.join(Target_.targetInfo);
+ return cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
+ distributionSetId);
};
}
}
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java
index befcd6a8a..1787d29e4 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java
@@ -95,7 +95,7 @@ public class TestDataUtil {
return distributionSetManagement.createDistributionSet(
buildDistributionSet(suffix != null && suffix.length() > 0 ? suffix : "DS", version,
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));
}
@@ -143,7 +143,7 @@ public class TestDataUtil {
}
public static List generateDistributionSetTags(final int number) {
- final List result = new ArrayList();
+ final List result = new ArrayList<>();
for (int i = 0; i < number; i++) {
result.add(new DistributionSetTag("tag" + i, "tagdesc" + i, "" + i));
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java
index 9bd532b5e..937a544a7 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java
@@ -33,12 +33,10 @@ public class ActionTest {
final Action timeforcedAction = new Action();
timeforcedAction.setActionType(ActionType.TIMEFORCED);
timeforcedAction.setForcedTime(timeForceTimeAt);
- final int knownHashCode = timeforcedAction.hashCode();
assertThat(timeforcedAction.isForce()).isFalse();
// wait until timeforce time is hit
Thread.sleep(sleepTime + 100);
assertThat(timeforcedAction.isForce()).isTrue();
- assertThat(timeforcedAction.hashCode()).isNotEqualTo(knownHashCode);
}
}
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java
index dd1e171ca..30f4093c2 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java
@@ -8,6 +8,8 @@
*/
package org.eclipse.hawkbit.repository;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -37,7 +39,7 @@ public class ArtifactManagementNoMongoDbTest extends AbstractIntegrationTest {
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")
public void createLocalArtifactWithMongoDbDown() throws IOException {
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();
- 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) {
+
+ }
}
}
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java
index 2929110dd..7c801a571 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java
@@ -352,11 +352,16 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB {
artifactManagement.loadLocalArtifactBinary(result).getFileInputStream()));
}
- @Test(expected = InsufficientPermissionException.class)
+ @Test
@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.")
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
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java
index a3913da2b..d77c137b1 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java
@@ -43,7 +43,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
distributionSetManagement);
Target savedTarget = targetManagement.createTarget(target);
- final List toAssign = new ArrayList();
+ final List toAssign = new ArrayList<>();
toAssign.add(savedTarget);
assertThat(savedTarget.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
@@ -75,7 +75,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
}
@Test
- @Description("Register a controller which not exist")
+ @Description("Register a controller which does not exist")
public void testfindOrRegisterTargetIfItDoesNotexist() {
final Target target = controllerManagament.findOrRegisterTargetIfItDoesNotexist("AA", null);
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(targetRepository.count()).as("Only 1 target should be registred").isEqualTo(1L);
+ // throws exception
try {
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) {
- // ok
+
}
}
@@ -101,7 +102,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
distributionSetManagement);
Target savedTarget = targetManagement.createTarget(target);
- final List toAssign = new ArrayList();
+ final List toAssign = new ArrayList<>();
toAssign.add(savedTarget);
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedTargets().iterator().next();
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,
System.currentTimeMillis());
actionStatusMessage3.addMessage("finish");
- savedAction = controllerManagament.addUpdateActionStatus(actionStatusMessage3, savedAction);
+ controllerManagament.addUpdateActionStatus(actionStatusMessage3, savedAction);
targetManagement.findTargetByControllerID("Rabbit").getTargetInfo().getUpdateStatus();
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementForDSTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DistributionSetManagementTest.java
similarity index 91%
rename from hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementForDSTest.java
rename to hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DistributionSetManagementTest.java
index 30f4a8cb0..90cecfc14 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementForDSTest.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DistributionSetManagementTest.java
@@ -33,6 +33,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
+import org.fest.assertions.core.Condition;
import org.junit.Test;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -44,15 +45,12 @@ import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
/**
- * {@link SoftwareManagement} test focused on {@link DistributionSet} and
- * {@link DistributionSetType} related stuff.
- *
- *
+ * {@link DistributionSetManagement} tests.
*
*/
@Features("Component Tests - Repository")
-@Stories("Software Management")
-public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
+@Stories("DistributionSet Management")
+public class DistributionSetManagementTest extends AbstractIntegrationTest {
@Test
@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");
}
- @Test(expected = EntityReadOnlyException.class)
+ @Test
@Description("Tests the unsuccessfull update of used distribution set type (module addition).")
public void addModuleToAssignedDistributionSetTypeFails() {
final DistributionSetType nonUpdatableType = distributionSetManagement
@@ -113,10 +111,17 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", nonUpdatableType, null));
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).")
public void removeModuleToAssignedDistributionSetTypeFails() {
DistributionSetType nonUpdatableType = distributionSetManagement
@@ -130,7 +135,12 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.createDistributionSet(new DistributionSet("newtypesoft", "1", "", nonUpdatableType, null));
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
@@ -152,22 +162,68 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.createDistributionSetType(new DistributionSetType("softdeleted", "to be deletd", ""));
assertThat(distributionSetTypeRepository.findAll()).contains(softDelete);
- final DistributionSet dsNewType = distributionSetManagement
- .createDistributionSet(new DistributionSet("newtypesoft", "1", "", softDelete, null));
+ distributionSetManagement.createDistributionSet(new DistributionSet("newtypesoft", "1", "", softDelete, null));
distributionSetManagement.deleteDistributionSetType(softDelete);
assertThat(distributionSetManagement.findDistributionSetTypeByKey("softdeleted").isDeleted()).isEqualTo(true);
}
- // TODO: kzimmerm: test N+1
-
- @Test(expected = EntityAlreadyExistsException.class)
+ @Test
@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() {
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 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() {
+ @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
@@ -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.")
public void updateDistributionSetModuleWithUndefinedTypeFails() {
final DistributionSet testSet = new DistributionSet();
final SoftwareModule module = new SoftwareModule(appType, "agent-hub2", "1.0.5", null, "");
// 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.")
public void updateDistributionSetUnsupportedModuleFails() {
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, "");
// 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
@@ -561,7 +627,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
// combine deleted and complete and type
- expected = new ArrayList();
+ expected = new ArrayList<>();
expected.addAll(ds100Group1);
expected.addAll(ds100Group2);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
@@ -570,7 +636,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(200)
.containsOnly(expected.toArray(new DistributionSet[0]));
- expected = new ArrayList();
+ expected = new ArrayList<>();
expected.add(dsDeleted);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
@@ -583,7 +649,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
- expected = new ArrayList();
+ expected = new ArrayList<>();
expected.add(dsNewType);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
assertThat(distributionSetManagement
@@ -591,7 +657,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.containsOnly(expected.toArray(new DistributionSet[0]));
// combine deleted and complete and type and text
- expected = new ArrayList();
+ expected = new ArrayList<>();
expected.addAll(ds100Group2);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setType(standardDsType).setSearchText("%test2");
@@ -615,7 +681,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
// combine deleted and complete and type and text and tag
- expected = new ArrayList();
+ expected = new ArrayList<>();
expected.addAll(ds100Group2);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
.setSearchText("%test2").setTagNames(Lists.newArrayList(dsTagA.getName()));
@@ -637,7 +703,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
private List sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable targs,
final Status status, final String... msgs) {
- final List result = new ArrayList();
+ final List result = new ArrayList<>();
for (final Target t : targs) {
final List findByTarget = actionRepository.findByTarget(t);
for (final Action action : findByTarget) {
@@ -730,7 +796,7 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
dsAssigned.getVersion());
final Target target = new Target("4712");
final Target savedTarget = targetManagement.createTarget(target);
- final List toAssign = new ArrayList();
+ final List toAssign = new ArrayList<>();
toAssign.add(savedTarget);
deploymentManagement.assignDistributionSet(dsAssigned, toAssign);
@@ -744,38 +810,6 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
.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 reOrderDSList(final Iterable buildDistributionSets,
- final DistributionSet... ds) {
- final List reOrderedList = new ArrayList<>();
-
- final Iterator 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,
final String... msgs) {
updActA.setStatus(status);
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java
index 49776e392..849cf8e30 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java
@@ -10,11 +10,11 @@ package org.eclipse.hawkbit.repository;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -24,14 +24,18 @@ import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
import org.eclipse.hawkbit.RandomGeneratedInputStream;
import org.eclipse.hawkbit.TestDataUtil;
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.Artifact;
+import org.eclipse.hawkbit.repository.model.CustomSoftwareModule;
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.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
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.TargetUpdateStatus;
import org.junit.Test;
@@ -51,6 +55,165 @@ import ru.yandex.qatools.allure.annotations.Stories;
@Stories("Software Management")
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 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 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
@Description("searched for software modules based on the various filter options, e.g. name,desc,type, version.")
public void findSoftwareModuleByFilters() {
@@ -105,7 +268,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
@Test
@Description("Searches for software modules based on a list of IDs.")
- public void findSoftwareModulesByIdAndType() {
+ public void findSoftwareModulesById() {
final List modules = new ArrayList();
@@ -118,6 +281,54 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
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
@Description("Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).")
public void deleteAssignedAndUnassignedSoftwareModuleTypes() {
@@ -419,32 +630,194 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
}
}
- /**
- *
- * @param findAll
- * @return
- */
- @SuppressWarnings("rawtypes")
- private Collection iterable2Collection(final Iterable iterable) {
- final Collection