org.jboss.errai.jpa.sync.server.DataSyncServiceImpl Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2015 Red Hat, Inc. and/or its affiliates.
*
* 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.jboss.errai.jpa.sync.server;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.SingularAttribute;
import org.jboss.errai.common.client.api.Assert;
import org.jboss.errai.jpa.sync.client.shared.ConflictResponse;
import org.jboss.errai.jpa.sync.client.shared.DataSyncService;
import org.jboss.errai.jpa.sync.client.shared.DeleteResponse;
import org.jboss.errai.jpa.sync.client.shared.EntityComparator;
import org.jboss.errai.jpa.sync.client.shared.IdChangeResponse;
import org.jboss.errai.jpa.sync.client.shared.JpaAttributeAccessor;
import org.jboss.errai.jpa.sync.client.shared.NewRemoteEntityResponse;
import org.jboss.errai.jpa.sync.client.shared.SyncRequestOperation;
import org.jboss.errai.jpa.sync.client.shared.SyncResponse;
import org.jboss.errai.jpa.sync.client.shared.SyncableDataSet;
import org.jboss.errai.jpa.sync.client.shared.UpdateResponse;
public class DataSyncServiceImpl implements DataSyncService {
private final EntityManager em;
private final JpaAttributeAccessor attributeAccessor;
private final EntityComparator entityComparator;
public DataSyncServiceImpl(EntityManager em, JpaAttributeAccessor attributeAccessor) {
this.em = Assert.notNull(em);
this.attributeAccessor = Assert.notNull(attributeAccessor);
this.entityComparator = new EntityComparator(em.getMetamodel(), attributeAccessor);
}
@Override
public List> coldSync(SyncableDataSet dataSet, List> syncRequestOps) {
TypedQuery query = dataSet.createQuery(em);
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy