refactored test data generation. Refactored entity factor methods.
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* Annotation to enable {@link ComponentScan} in the resource package to setup
|
||||
* all {@link Controller} annotated classes and setup the REST-Resources for the
|
||||
* Management API.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@Import(RepositoryApplicationConfiguration.class)
|
||||
public @interface EnableJpaRepository {
|
||||
|
||||
}
|
||||
@@ -47,11 +47,10 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess
|
||||
@EnableTransactionManagement
|
||||
@EnableJpaAuditing
|
||||
@EnableAspectJAutoProxy
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
|
||||
/**
|
||||
* @return the {@link SystemSecurityContext} singleton bean which make it
|
||||
* accessible in beans which cannot access the service directly,
|
||||
|
||||
@@ -288,4 +288,14 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
final boolean overrideExisting, final String contentType) {
|
||||
return createLocalArtifact(inputStream, moduleId, filename, null, null, overrideExisting, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countLocalArtifactsAll() {
|
||||
return localArtifactRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countExternalArtifactsAll() {
|
||||
return externalArtifactRepository.count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -55,7 +54,6 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -438,33 +436,4 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
return updateTargetStatus(target, null, System.currentTimeMillis(), address);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public ActionStatus generateActionStatus() {
|
||||
return new JpaActionStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt,
|
||||
final String message) {
|
||||
return new JpaActionStatus((JpaAction) action, status, occurredAt, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt,
|
||||
final Collection<String> messages) {
|
||||
|
||||
final ActionStatus result = new JpaActionStatus((JpaAction) action, status, occurredAt, null);
|
||||
messages.forEach(result::addMessage);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt) {
|
||||
return new JpaActionStatus(action, status, occurredAt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -155,7 +154,8 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true)
|
||||
public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, final String... targetIDs) {
|
||||
return assignDistributionSet(dsID, ActionType.FORCED, org.eclipse.hawkbit.repository.model.Constants.NO_FORCE_TIME, targetIDs);
|
||||
return assignDistributionSet(dsID, ActionType.FORCED,
|
||||
org.eclipse.hawkbit.repository.model.Constants.NO_FORCE_TIME, targetIDs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -683,12 +683,6 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
return actionRepository.findByRolloutAndStatus((JpaRollout) rollout, actionStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public Action generateAction() {
|
||||
return new JpaAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ActionStatus> findActionStatusAll(final Pageable pageable) {
|
||||
return convertAcSPage(actionStatusRepository.findAll(pageable), pageable);
|
||||
@@ -697,4 +691,19 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
private static Page<ActionStatus> convertAcSPage(final Page<JpaActionStatus> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionStatusAll() {
|
||||
return actionStatusRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionsAll() {
|
||||
return actionRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Action> findActionsByDistributionSet(final Pageable pageable, final DistributionSet ds) {
|
||||
return actionRepository.findByDistributionSet(pageable, (JpaDistributionSet) ds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -739,45 +738,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSetType generateDistributionSetType() {
|
||||
return new JpaDistributionSetType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSet generateDistributionSet() {
|
||||
return new JpaDistributionSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSetMetadata generateDistributionSetMetadata() {
|
||||
return new JpaDistributionSetMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSetMetadata generateDistributionSetMetadata(final DistributionSet distributionSet,
|
||||
final String key, final String value) {
|
||||
return new JpaDistributionSetMetadata(key, distributionSet, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSetType generateDistributionSetType(final String key, final String name,
|
||||
final String description) {
|
||||
return new JpaDistributionSetType(key, name, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSet generateDistributionSet(final String name, final String version, final String description,
|
||||
final DistributionSetType type, final Collection<SoftwareModule> moduleList) {
|
||||
return new JpaDistributionSet(name, version, description, type, moduleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDistributionSetsByType(final DistributionSetType type) {
|
||||
return distributionSetRepository.countByType((JpaDistributionSetType) type);
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
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.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* JPA Implementation of {@link EntityFactory}.
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class JpaEntityFactory implements EntityFactory {
|
||||
|
||||
@Override
|
||||
public DistributionSetType generateDistributionSetType() {
|
||||
return new JpaDistributionSetType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSet generateDistributionSet() {
|
||||
return new JpaDistributionSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSetMetadata generateDistributionSetMetadata() {
|
||||
return new JpaDistributionSetMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSetMetadata generateDistributionSetMetadata(final DistributionSet distributionSet,
|
||||
final String key, final String value) {
|
||||
return new JpaDistributionSetMetadata(key, distributionSet, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSetType generateDistributionSetType(final String key, final String name,
|
||||
final String description) {
|
||||
return new JpaDistributionSetType(key, name, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSet generateDistributionSet(final String name, final String version, final String description,
|
||||
final DistributionSetType type, final Collection<SoftwareModule> moduleList) {
|
||||
return new JpaDistributionSet(name, version, description, type, moduleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Target generateTarget(final String controllerId) {
|
||||
return new JpaTarget(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetTag generateTargetTag() {
|
||||
return new JpaTargetTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSetTag generateDistributionSetTag() {
|
||||
return new JpaDistributionSetTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetTag generateTargetTag(final String name, final String description, final String colour) {
|
||||
return new JpaTargetTag(name, description, colour);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSetTag generateDistributionSetTag(final String name, final String description,
|
||||
final String colour) {
|
||||
return new JpaDistributionSetTag(name, description, colour);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetTag generateTargetTag(final String name) {
|
||||
return new JpaTargetTag(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSetTag generateDistributionSetTag(final String name) {
|
||||
return new JpaDistributionSetTag(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetFilterQuery generateTargetFilterQuery() {
|
||||
return new JpaTargetFilterQuery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoftwareModuleType generateSoftwareModuleType() {
|
||||
return new JpaSoftwareModuleType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoftwareModule generateSoftwareModule() {
|
||||
return new JpaSoftwareModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoftwareModule generateSoftwareModule(final SoftwareModuleType type, final String name, final String version,
|
||||
final String description, final String vendor) {
|
||||
|
||||
return new JpaSoftwareModule(type, name, version, description, vendor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoftwareModuleMetadata generateSoftwareModuleMetadata() {
|
||||
return new JpaSoftwareModuleMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoftwareModuleMetadata generateSoftwareModuleMetadata(final SoftwareModule softwareModule, final String key,
|
||||
final String value) {
|
||||
return new JpaSoftwareModuleMetadata(key, softwareModule, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoftwareModuleType generateSoftwareModuleType(final String key, final String name, final String description,
|
||||
final int maxAssignments) {
|
||||
return new JpaSoftwareModuleType(key, name, description, maxAssignments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rollout generateRollout() {
|
||||
return new JpaRollout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RolloutGroup generateRolloutGroup() {
|
||||
return new JpaRolloutGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action generateAction() {
|
||||
return new JpaAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionStatus generateActionStatus() {
|
||||
return new JpaActionStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt,
|
||||
final String message) {
|
||||
return new JpaActionStatus((JpaAction) action, status, occurredAt, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt,
|
||||
final Collection<String> messages) {
|
||||
|
||||
final ActionStatus result = new JpaActionStatus((JpaAction) action, status, occurredAt, null);
|
||||
messages.forEach(result::addMessage);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt) {
|
||||
return new JpaActionStatus(action, status, occurredAt);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,7 +49,6 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -201,9 +200,4 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
return new PageImpl<>(targetWithActionStatus, pageRequest, totalCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public RolloutGroup generateRolloutGroup() {
|
||||
return new JpaRolloutGroup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,9 +667,4 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
return ((float) finished / (float) totalGroup) * 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public Rollout generateRollout() {
|
||||
return new JpaRollout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -663,44 +662,4 @@ public class JpaSoftwareManagement implements SoftwareManagement {
|
||||
return types.stream().map(this::createSoftwareModuleType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public SoftwareModuleType generateSoftwareModuleType() {
|
||||
return new JpaSoftwareModuleType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public SoftwareModule generateSoftwareModule() {
|
||||
return new JpaSoftwareModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public SoftwareModule generateSoftwareModule(final SoftwareModuleType type, final String name, final String version,
|
||||
final String description, final String vendor) {
|
||||
|
||||
return new JpaSoftwareModule(type, name, version, description, vendor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public SoftwareModuleMetadata generateSoftwareModuleMetadata() {
|
||||
return new JpaSoftwareModuleMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public SoftwareModuleMetadata generateSoftwareModuleMetadata(final SoftwareModule softwareModule, final String key,
|
||||
final String value) {
|
||||
return new JpaSoftwareModuleMetadata(key, softwareModule, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public SoftwareModuleType generateSoftwareModuleType(final String key, final String name, final String description,
|
||||
final int maxAssignments) {
|
||||
return new JpaSoftwareModuleType(key, name, description, maxAssignments);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -259,28 +259,6 @@ public class JpaSystemManagement implements SystemManagement {
|
||||
return tenantMetaDataRepository.save((JpaTenantMetaData) metaData);
|
||||
}
|
||||
|
||||
private DistributionSetType createStandardSoftwareDataSetup() {
|
||||
final SoftwareModuleType eclApp = softwareModuleTypeRepository.save(new JpaSoftwareModuleType("application",
|
||||
"ECL Application", "Edge Controller Linux base application type", 1));
|
||||
final SoftwareModuleType eclOs = softwareModuleTypeRepository.save(
|
||||
new JpaSoftwareModuleType("os", "ECL OS", "Edge Controller Linux operation system image type", 1));
|
||||
final SoftwareModuleType eclJvm = softwareModuleTypeRepository.save(
|
||||
new JpaSoftwareModuleType("runtime", "ECL JVM", "Edge Controller Linux java virtual machine type.", 1));
|
||||
|
||||
distributionSetTypeRepository.save((JpaDistributionSetType) new JpaDistributionSetType("ecl_os", "OS only",
|
||||
"Standard Edge Controller Linux distribution set type.").addMandatoryModuleType(eclOs));
|
||||
|
||||
distributionSetTypeRepository.save((JpaDistributionSetType) new JpaDistributionSetType("ecl_os_app",
|
||||
"OS with optional app", "Standard Edge Controller Linux distribution set type. OS only.")
|
||||
.addMandatoryModuleType(eclOs).addOptionalModuleType(eclApp));
|
||||
|
||||
return distributionSetTypeRepository.save(
|
||||
(JpaDistributionSetType) new JpaDistributionSetType("ecl_os_app_jvm", "OS with optional app and jvm",
|
||||
"Standard Edge Controller Linux distribution set type. OS with optional application.")
|
||||
.addMandatoryModuleType(eclOs).addOptionalModuleType(eclApp)
|
||||
.addOptionalModuleType(eclJvm));
|
||||
}
|
||||
|
||||
/**
|
||||
* A implementation of the {@link KeyGenerator} to generate a key based on
|
||||
* either the {@code createInitialTenant} thread local and the
|
||||
@@ -303,4 +281,18 @@ public class JpaSystemManagement implements SystemManagement {
|
||||
initialTenantCreation.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
private DistributionSetType createStandardSoftwareDataSetup() {
|
||||
final SoftwareModuleType app = softwareModuleTypeRepository
|
||||
.save(new JpaSoftwareModuleType("application", "Application", "Application Addons", Integer.MAX_VALUE));
|
||||
final SoftwareModuleType os = softwareModuleTypeRepository
|
||||
.save(new JpaSoftwareModuleType("os", "Firmware", "Core firmware or operationg system", 1));
|
||||
|
||||
distributionSetTypeRepository.save((JpaDistributionSetType) new JpaDistributionSetType("os_app", "With app(s)",
|
||||
"Default type with Firmware/OS and optional app(s).").addMandatoryModuleType(os)
|
||||
.addOptionalModuleType(app));
|
||||
|
||||
return distributionSetTypeRepository.save((JpaDistributionSetType) new JpaDistributionSetType("os", "OS only",
|
||||
"Default type with Firmware/OS only.").addMandatoryModuleType(os));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -287,41 +286,4 @@ public class JpaTagManagement implements TagManagement {
|
||||
return convertDsPage(distributionSetTagRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public TargetTag generateTargetTag() {
|
||||
return new JpaTargetTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSetTag generateDistributionSetTag() {
|
||||
return new JpaDistributionSetTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public TargetTag generateTargetTag(final String name, final String description, final String colour) {
|
||||
return new JpaTargetTag(name, description, colour);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSetTag generateDistributionSetTag(final String name, final String description,
|
||||
final String colour) {
|
||||
return new JpaDistributionSetTag(name, description, colour);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public TargetTag generateTargetTag(final String name) {
|
||||
return new JpaTargetTag(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public DistributionSetTag generateDistributionSetTag(final String name) {
|
||||
return new JpaDistributionSetTag(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,9 +109,4 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
return targetFilterQueryRepository.save((JpaTargetFilterQuery) targetFilterQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetFilterQuery generateTargetFilterQuery() {
|
||||
return new JpaTargetFilterQuery();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -403,7 +402,6 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public Target unAssignTag(final String controllerID, final TargetTag targetTag) {
|
||||
// TODO : optimize this, findone?
|
||||
final List<Target> allTargets = new ArrayList<>(targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID))));
|
||||
final List<Target> unAssignTag = unAssignTag(allTargets, targetTag);
|
||||
@@ -673,9 +671,4 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public Target generateTarget(final String controllerId) {
|
||||
return new JpaTarget(controllerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,16 +53,11 @@ public class CacheFieldEntityListener {
|
||||
@SuppressWarnings("rawtypes")
|
||||
final String id = ((Identifiable) target).getId().toString();
|
||||
final Class<? extends Object> type = target.getClass();
|
||||
findCacheFields(type, id, new CacheFieldCallback() {
|
||||
@Override
|
||||
public void fromCache(final Field field, final String cacheKey, final Serializable id)
|
||||
throws IllegalAccessException {
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
final ValueWrapper valueWrapper = cache
|
||||
.get(CacheKeys.entitySpecificCacheKey(id.toString(), cacheKey));
|
||||
if (valueWrapper != null && valueWrapper.get() != null) {
|
||||
FieldUtils.writeField(field, target, valueWrapper.get(), true);
|
||||
}
|
||||
findCacheFields(type, id, (field, cacheKey, id1) -> {
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
final ValueWrapper valueWrapper = cache.get(CacheKeys.entitySpecificCacheKey(id1.toString(), cacheKey));
|
||||
if (valueWrapper != null && valueWrapper.get() != null) {
|
||||
FieldUtils.writeField(field, target, valueWrapper.get(), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -82,13 +77,9 @@ public class CacheFieldEntityListener {
|
||||
@SuppressWarnings("rawtypes")
|
||||
final String id = ((Identifiable) target).getId().toString();
|
||||
final Class<? extends Object> type = target.getClass();
|
||||
findCacheFields(type, id, new CacheFieldCallback() {
|
||||
@Override
|
||||
public void fromCache(final Field field, final String cacheKey, final Serializable id)
|
||||
throws IllegalAccessException {
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
cache.evict(CacheKeys.entitySpecificCacheKey(id.toString(), cacheKey));
|
||||
}
|
||||
findCacheFields(type, id, (field, cacheKey, id1) -> {
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
cache.evict(CacheKeys.entitySpecificCacheKey(id1.toString(), cacheKey));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -109,6 +100,7 @@ public class CacheFieldEntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface CacheFieldCallback {
|
||||
/**
|
||||
* callback methods which is called by the
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model.helper;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* A singleton bean which holds {@link SystemManagement} service and makes it
|
||||
* accessible to beans which are not managed by spring, e.g. JPA entities.
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
public final class SystemManagementHolder {
|
||||
|
||||
private static final SystemManagementHolder INSTANCE = new SystemManagementHolder();
|
||||
|
||||
@Autowired
|
||||
private SystemManagement systemManagement;
|
||||
|
||||
private SystemManagementHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the singleton {@link SystemManagementHolder} instance
|
||||
*/
|
||||
public static SystemManagementHolder getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the systemManagement
|
||||
*/
|
||||
public SystemManagement getSystemManagement() {
|
||||
return systemManagement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param systemManagement
|
||||
* the systemManagement to set
|
||||
*/
|
||||
public void setSystemManagement(final SystemManagement systemManagement) {
|
||||
this.systemManagement = systemManagement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link SystemManagement#currentTenant()}.
|
||||
*/
|
||||
public String currentTenant() {
|
||||
return systemManagement.currentTenant();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,8 +12,9 @@ import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* Verifies {@link RolloutGroup#getErrorConditionExp()}.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RolloutGroupConditionEvaluator {
|
||||
|
||||
default boolean verifyExpression(final String expression) {
|
||||
|
||||
Reference in New Issue
Block a user