Merge branch 'master' of github.com:thingsboard/thingsboard
This commit is contained in:
		
						commit
						f75dc9aff1
					
				@ -33,9 +33,7 @@ import javax.persistence.PersistenceContext;
 | 
			
		||||
import javax.persistence.Query;
 | 
			
		||||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@SqlDao
 | 
			
		||||
@Repository
 | 
			
		||||
public abstract class AbstractComponentDescriptorInsertRepository {
 | 
			
		||||
public abstract class AbstractComponentDescriptorInsertRepository implements ComponentDescriptorInsertRepository {
 | 
			
		||||
 | 
			
		||||
    @PersistenceContext
 | 
			
		||||
    protected EntityManager entityManager;
 | 
			
		||||
@ -43,8 +41,6 @@ public abstract class AbstractComponentDescriptorInsertRepository {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    protected PlatformTransactionManager transactionManager;
 | 
			
		||||
 | 
			
		||||
    public abstract ComponentDescriptorEntity saveOrUpdate(ComponentDescriptorEntity entity);
 | 
			
		||||
 | 
			
		||||
    protected ComponentDescriptorEntity saveAndGet(ComponentDescriptorEntity entity, String insertOrUpdateOnPrimaryKeyConflict, String insertOrUpdateOnUniqueKeyConflict) {
 | 
			
		||||
        ComponentDescriptorEntity componentDescriptorEntity = null;
 | 
			
		||||
        TransactionStatus insertTransaction = getTransactionStatus(TransactionDefinition.PROPAGATION_REQUIRED);
 | 
			
		||||
@ -94,4 +90,4 @@ public abstract class AbstractComponentDescriptorInsertRepository {
 | 
			
		||||
        insertDefinition.setPropagationBehavior(propagationRequired);
 | 
			
		||||
        return transactionManager.getTransaction(insertDefinition);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,24 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2019 The Thingsboard Authors
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
package org.thingsboard.server.dao.sql.component;
 | 
			
		||||
 | 
			
		||||
import org.thingsboard.server.dao.model.sql.ComponentDescriptorEntity;
 | 
			
		||||
 | 
			
		||||
public interface ComponentDescriptorInsertRepository {
 | 
			
		||||
 | 
			
		||||
    ComponentDescriptorEntity saveOrUpdate(ComponentDescriptorEntity entity);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -19,9 +19,10 @@ import org.springframework.stereotype.Repository;
 | 
			
		||||
import org.thingsboard.server.common.data.UUIDConverter;
 | 
			
		||||
import org.thingsboard.server.dao.model.sql.ComponentDescriptorEntity;
 | 
			
		||||
import org.thingsboard.server.dao.util.HsqlDao;
 | 
			
		||||
import org.thingsboard.server.dao.util.SqlDao;
 | 
			
		||||
import org.thingsboard.server.dao.util.SqlTsDao;
 | 
			
		||||
 | 
			
		||||
@SqlTsDao
 | 
			
		||||
@SqlDao
 | 
			
		||||
@HsqlDao
 | 
			
		||||
@Repository
 | 
			
		||||
public class HsqlComponentDescriptorInsertRepository extends AbstractComponentDescriptorInsertRepository {
 | 
			
		||||
@ -47,4 +48,4 @@ public class HsqlComponentDescriptorInsertRepository extends AbstractComponentDe
 | 
			
		||||
        return "MERGE INTO component_descriptor USING (VALUES :id, :actions, :clazz, :configuration_descriptor, :name, :scope, :search_text, :type) I (id, actions, clazz, configuration_descriptor, name, scope, search_text, type) ON " + conflictStatement + " WHEN MATCHED THEN UPDATE SET component_descriptor.id = I.id, component_descriptor.actions = I.actions, component_descriptor.clazz = I.clazz, component_descriptor.configuration_descriptor = I.configuration_descriptor, component_descriptor.name = I.name, component_descriptor.scope = I.scope, component_descriptor.search_text = I.search_text, component_descriptor.type = I.type" +
 | 
			
		||||
                " WHEN NOT MATCHED THEN INSERT (id, actions, clazz, configuration_descriptor, name, scope, search_text, type) VALUES (I.id, I.actions, I.clazz, I.configuration_descriptor, I.name, I.scope, I.search_text, I.type)";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -52,7 +52,7 @@ public class JpaBaseComponentDescriptorDao extends JpaAbstractSearchTextDao<Comp
 | 
			
		||||
    private ComponentDescriptorRepository componentDescriptorRepository;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AbstractComponentDescriptorInsertRepository componentDescriptorInsertRepository;
 | 
			
		||||
    private ComponentDescriptorInsertRepository componentDescriptorInsertRepository;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected Class<ComponentDescriptorEntity> getEntityClass() {
 | 
			
		||||
 | 
			
		||||
@ -18,9 +18,10 @@ package org.thingsboard.server.dao.sql.component;
 | 
			
		||||
import org.springframework.stereotype.Repository;
 | 
			
		||||
import org.thingsboard.server.dao.model.sql.ComponentDescriptorEntity;
 | 
			
		||||
import org.thingsboard.server.dao.util.PsqlDao;
 | 
			
		||||
import org.thingsboard.server.dao.util.SqlDao;
 | 
			
		||||
import org.thingsboard.server.dao.util.SqlTsDao;
 | 
			
		||||
 | 
			
		||||
@SqlTsDao
 | 
			
		||||
@SqlDao
 | 
			
		||||
@PsqlDao
 | 
			
		||||
@Repository
 | 
			
		||||
public class PsqlComponentDescriptorInsertRepository extends AbstractComponentDescriptorInsertRepository {
 | 
			
		||||
@ -54,4 +55,4 @@ public class PsqlComponentDescriptorInsertRepository extends AbstractComponentDe
 | 
			
		||||
    private static String getUpdateStatement(String id) {
 | 
			
		||||
        return "actions = :actions, " + id + ", configuration_descriptor = :configuration_descriptor, name = :name, scope = :scope, search_text = :search_text, type = :type";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user