Removed JPA dependencies from runtime. Test only now.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-05-31 20:50:22 +02:00
parent e054a171ea
commit 13f9791891
54 changed files with 699 additions and 243 deletions

View File

@@ -26,7 +26,6 @@ import org.springframework.stereotype.Controller;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Configuration
@ComponentScan
@Import(RepositoryApplicationConfiguration.class)
public @interface EnableJpaRepository {

View File

@@ -47,8 +47,8 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess
@EnableTransactionManagement
@EnableJpaAuditing
@EnableAspectJAutoProxy
@ComponentScan
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
/**

View File

@@ -19,13 +19,14 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException;
import org.eclipse.hawkbit.repository.exception.ToManyStatusEntriesException;
import org.eclipse.hawkbit.repository.jpa.cache.CacheWriteNotify;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus_;
@@ -98,6 +99,9 @@ public class JpaControllerManagement implements ControllerManagement {
@Autowired
private TenantConfigurationManagement tenantConfigurationManagement;
@Autowired
private CacheWriteNotify cacheWriteNotify;
@Override
public String getPollingTime() {
final TenantConfigurationKey configurationKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
@@ -230,7 +234,8 @@ public class JpaControllerManagement implements ControllerManagement {
private void handleFinishedCancelation(final ActionStatus actionStatus, final JpaAction action) {
// in case of successful cancellation we also report the success at
// the canceled action itself.
actionStatus.addMessage(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Cancellation completion is finished sucessfully.");
actionStatus.addMessage(
RepositoryConstants.SERVER_MESSAGE_PREFIX + "Cancellation completion is finished sucessfully.");
DeploymentHelper.successCancellation(action, actionRepository, targetManagement, targetInfoRepository,
entityManager);
}
@@ -436,4 +441,9 @@ public class JpaControllerManagement implements ControllerManagement {
return updateTargetStatus(target, null, System.currentTimeMillis(), address);
}
@Override
public void downloadProgressPercent(final long statusId, final int progressPercent) {
cacheWriteNotify.downloadProgressPercent(statusId, progressPercent);
}
}

View File

@@ -17,6 +17,7 @@ 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.JpaLocalArtifact;
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout;
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
@@ -32,6 +33,7 @@ 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.LocalArtifact;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -198,4 +200,9 @@ public class JpaEntityFactory implements EntityFactory {
return new JpaActionStatus(action, status, occurredAt);
}
@Override
public LocalArtifact generateLocalArtifact() {
return new JpaLocalArtifact();
}
}

View File

@@ -11,9 +11,11 @@ package org.eclipse.hawkbit.repository.jpa;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.repository.TargetFields;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetFilterQuery;
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
import org.eclipse.hawkbit.repository.jpa.specifications.TargetFilterQuerySpecification;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
@@ -109,4 +111,10 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
return targetFilterQueryRepository.save((JpaTargetFilterQuery) targetFilterQuery);
}
@Override
public boolean verifyTargetFilterQuerySyntax(final String query) {
RSQLUtility.parse(query, TargetFields.class);
return true;
}
}

View File

@@ -97,6 +97,8 @@ public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEn
* @see org.eclipse.hawkbit.repository.model.BaseEntity#equals(java.lang.Object)
*/
@Override
// exception squid:S2259 - obj is checked for null in super
@SuppressWarnings("squid:S2259")
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;

View File

@@ -67,6 +67,8 @@ public class JpaDistributionSetMetadata extends AbstractJpaMetaData implements D
}
@Override
// exception squid:S2259 - obj is checked for null in super
@SuppressWarnings("squid:S2259")
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;

View File

@@ -1,55 +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.jpa.model.CacheFieldEntityListener;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.eventbus.EventBus;
/**
* A singleton bean which holds the {@link EventBus} to have to the cache
* manager in beans not instantiated by spring e.g. JPA entities or
* {@link CacheFieldEntityListener} which cannot be autowired.
*
*/
public final class EventBusHolder {
private static final EventBusHolder SINGLETON = new EventBusHolder();
@Autowired
private EventBus eventBus;
private EventBusHolder() {
}
/**
* @return the cache manager holder singleton instance
*/
public static EventBusHolder getInstance() {
return SINGLETON;
}
/**
* @return the eventBus
*/
public EventBus getEventBus() {
return eventBus;
}
/**
* @param eventBus
* the eventBus to set
*/
public void setEventBus(final EventBus eventBus) {
this.eventBus = eventBus;
}
}