001/* 002 * (C) Copyright 2006-2017 Nuxeo (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Florent Guillaume 018 * Benoit Delbosc 019 */ 020package org.nuxeo.ecm.core.storage.sql; 021 022import java.io.Serializable; 023import java.util.Calendar; 024import java.util.Collection; 025import java.util.Map; 026import java.util.Set; 027 028import org.nuxeo.ecm.core.api.IterableQueryResult; 029import org.nuxeo.ecm.core.api.PartialList; 030import org.nuxeo.ecm.core.api.ScrollResult; 031import org.nuxeo.ecm.core.query.QueryFilter; 032 033/** 034 * A {@link Mapper} that uses a {@link UnifiedCachingRowMapper} for row-related operation, and delegates to the 035 * {@link Mapper} for others. 036 */ 037public class UnifiedCachingMapper extends UnifiedCachingRowMapper implements CachingMapper { 038 039 /** 040 * The {@link Mapper} to which operations are delegated. 041 */ 042 public Mapper mapper; 043 044 @Override 045 public void initialize(String repositoryName, Model model, Mapper mapper, 046 VCSInvalidationsPropagator invalidationsPropagator, Map<String, String> properties) { 047 super.initialize(repositoryName, model, mapper, invalidationsPropagator, properties); 048 this.mapper = mapper; 049 } 050 051 @Override 052 public ScrollResult scroll(String query, int batchSize, int keepAliveSeconds) { 053 return mapper.scroll(query, batchSize, keepAliveSeconds); 054 } 055 056 @Override 057 public ScrollResult scroll(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) { 058 return mapper.scroll(query, queryFilter, batchSize, keepAliveSeconds); 059 } 060 061 @Override 062 public ScrollResult scroll(String scrollId) { 063 return mapper.scroll(scrollId); 064 } 065 066 @Override 067 public Identification getIdentification() { 068 return mapper.getIdentification(); 069 } 070 071 @Override 072 public void close() { 073 super.close(); 074 mapper.close(); 075 } 076 077 @Override 078 public int getTableSize(String tableName) { 079 return mapper.getTableSize(tableName); 080 } 081 082 @Override 083 public Serializable getRootId(String repositoryId) { 084 return mapper.getRootId(repositoryId); 085 } 086 087 @Override 088 public void setRootId(Serializable repositoryId, Serializable id) { 089 mapper.setRootId(repositoryId, id); 090 } 091 092 @Override 093 public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, 094 boolean countTotal) { 095 return mapper.query(query, queryType, queryFilter, countTotal); 096 } 097 098 @Override 099 public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo) { 100 return mapper.query(query, queryType, queryFilter, countUpTo); 101 } 102 103 @Override 104 public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, 105 boolean distinctDocuments, Object... params) { 106 return mapper.queryAndFetch(query, queryType, queryFilter, distinctDocuments, params); 107 } 108 109 @Override 110 public PartialList<Map<String, Serializable>> queryProjection(String query, String queryType, 111 QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object... params) { 112 return mapper.queryProjection(query, queryType, queryFilter, distinctDocuments, countUpTo, params); 113 } 114 115 @Override 116 public Set<Serializable> getAncestorsIds(Collection<Serializable> ids) { 117 return mapper.getAncestorsIds(ids); 118 } 119 120 @Override 121 public void updateReadAcls() { 122 mapper.updateReadAcls(); 123 } 124 125 @Override 126 public void rebuildReadAcls() { 127 mapper.rebuildReadAcls(); 128 } 129 130 @Override 131 public int getClusterNodeIdType() { 132 return mapper.getClusterNodeIdType(); 133 } 134 135 @Override 136 public void createClusterNode(Serializable nodeId) { 137 mapper.createClusterNode(nodeId); 138 } 139 140 @Override 141 public void removeClusterNode(Serializable nodeId) { 142 mapper.removeClusterNode(nodeId); 143 } 144 145 @Override 146 public void insertClusterInvalidations(Serializable nodeId, VCSInvalidations invalidations) { 147 mapper.insertClusterInvalidations(nodeId, invalidations); 148 } 149 150 @Override 151 public VCSInvalidations getClusterInvalidations(Serializable nodeId) { 152 return mapper.getClusterInvalidations(nodeId); 153 } 154 155 @Override 156 public void markReferencedBinaries() { 157 mapper.markReferencedBinaries(); 158 } 159 160 @Override 161 public int cleanupDeletedRows(int max, Calendar beforeTime) { 162 return mapper.cleanupDeletedRows(max, beforeTime); 163 } 164 165}