X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=runtime%2Forg.argeo.slc.support.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjcr%2Fdao%2FAbstractSlcJcrDao.java;fp=runtime%2Forg.argeo.slc.support.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjcr%2Fdao%2FAbstractSlcJcrDao.java;h=0000000000000000000000000000000000000000;hb=a0a151ee3a0aed29a3cb03d81e35d540ca9fdb03;hp=08c99c6a0d162158508ed69f39642193a98a2ba6;hpb=5fe677bf811739592b1089471181e39f9cbe4f3f;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/AbstractSlcJcrDao.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/AbstractSlcJcrDao.java deleted file mode 100644 index 08c99c6a0..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/AbstractSlcJcrDao.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * 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.argeo.slc.jcr.dao; - -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -import javax.jcr.NamespaceRegistry; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.jcr.query.Query; - -import org.argeo.ArgeoException; -import org.argeo.jcr.JcrUtils; -import org.argeo.jcr.NodeMapper; -import org.argeo.jcr.NodeMapperProvider; -import org.argeo.slc.runtime.SlcAgentDescriptor; -import org.argeo.slc.test.TestResult; -import org.argeo.slc.test.TestRunDescriptor; - -public abstract class AbstractSlcJcrDao { - - private Session session; - - // protected Workspace workspace; - // protected QueryManager queryManager; - protected NodeMapper nodeMapper; - - // We inject the nodeMapperProvider that define a default node mapper as an - // entry point of the NodeMapper - private NodeMapperProvider nodeMapperProvider; - - public void init() { - nodeMapper = getNodeMapperProvider().findNodeMapper(null); - // JcrUtils.registerNamespaceSafely(session, "slc", - // "http://www.argeo.org/slc/0.12"); - - } - - public void setSession(Session session) { - this.session = session; - } - - protected Session getSession() { - return session; - } - - // IoC - public void setNodeMapperProvider(NodeMapperProvider nodeMapperProvider) { - this.nodeMapperProvider = nodeMapperProvider; - } - - // TODO : define a strategy to define basePathes - protected String basePath(TestResult testResult) { - Calendar cal = new GregorianCalendar(); - cal.setTime(new Date()); - return "/slc/testresults/" + JcrUtils.dateAsPath(cal) + "testresult"; - } - - protected String basePath(SlcAgentDescriptor slcAgentDescriptor) { - return "/slc/agents/" - + JcrUtils.hostAsPath(slcAgentDescriptor.getHost()) + "/agent"; - } - - protected String basePath(TestRunDescriptor testRunDescriptor) { - return "/slc/testruns/" + testRunDescriptor.getSlcExecutionUuid() - + "/testrun"; - } - - protected NodeMapperProvider getNodeMapperProvider() { - return this.nodeMapperProvider; - } - - protected Query createQuery(String query, String type) { - try { - return getSession().getWorkspace().getQueryManager().createQuery( - query, type); - } catch (RepositoryException e) { - throw new ArgeoException("Cannot create query " + query, e); - } - } -}