001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019package org.nuxeo.ecm.platform.scanimporter.service;
020
021import java.io.Serializable;
022
023import org.nuxeo.common.utils.Path;
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026
027/**
028 * XMap Descriptor for importer config
029 *
030 * @author Thierry Delprat
031 */
032@XObject("importerConfig")
033public class ImporterConfig implements Serializable {
034
035    private static final long serialVersionUID = 1L;
036
037    @XNode("sourcePath")
038    protected String sourcePath;
039
040    @XNode("processedPath")
041    protected String processedPath;
042
043    @XNode("nbThreads")
044    protected Integer nbThreads = 1;
045
046    @XNode("batchSize")
047    protected Integer batchSize = 10;
048
049    @XNode("transactionTimeout")
050    protected Integer transactionTimeout = 0;
051
052    @XNode("targetPath")
053    protected String targetPath = "/";
054
055    @XNode("useXMLMapping")
056    protected boolean useXMLMapping = true;
057
058    @XNode("createInitialFolder")
059    protected boolean createInitialFolder = true;
060
061    @XNode("mergeInitialFolder")
062    protected boolean mergeInitialFolder = false;
063
064    @XNode("update")
065    protected boolean update = true;
066
067    public String getSourcePath() {
068        if (sourcePath == null) {
069            return null;
070        }
071        return new Path(sourcePath).removeTrailingSeparator().toString();
072    }
073
074    public String getProcessedPath() {
075        return processedPath;
076    }
077
078    public Integer getNbThreads() {
079        return nbThreads;
080    }
081
082    public Integer getBatchSize() {
083        return batchSize;
084    }
085
086    /**
087     * @since 5.9.4
088     */
089    public Integer getTransactionTimeout() {
090        return transactionTimeout;
091    }
092
093    public String getTargetPath() {
094        if (targetPath == null) {
095            return null;
096        }
097        return new Path(targetPath).removeTrailingSeparator().toString();
098    }
099
100    public boolean useXMLMapping() {
101        return useXMLMapping;
102    }
103
104    public boolean isCreateInitialFolder() {
105        return createInitialFolder;
106    }
107
108    public boolean isUpdate() {
109        return update;
110    }
111
112    public void setCreateInitialFolder(boolean createInitialFolder) {
113        this.createInitialFolder = createInitialFolder;
114    }
115
116    public boolean isMergeInitialFolder() {
117        return mergeInitialFolder;
118    }
119
120    public void setMergeInitialFolder(boolean mergeInitialFolder) {
121        this.mergeInitialFolder = mergeInitialFolder;
122    }
123
124    public void setSourcePath(String sourcePath) {
125        this.sourcePath = sourcePath;
126    }
127
128    public void setProcessedPath(String processedPath) {
129        this.processedPath = processedPath;
130    }
131
132    public void setNbThreads(Integer nbThreads) {
133        this.nbThreads = nbThreads;
134    }
135
136    public void setBatchSize(Integer batchSize) {
137        this.batchSize = batchSize;
138    }
139
140    /**
141     * @since 5.9.4
142     */
143    public void setTransactionTimeout(Integer transactionTimeout) {
144        this.transactionTimeout = transactionTimeout;
145    }
146
147    public void setTargetPath(String tagetPath) {
148        this.targetPath = tagetPath;
149    }
150
151    public void setUseXMLMapping(boolean useXMLMapping) {
152        this.useXMLMapping = useXMLMapping;
153    }
154
155    public void setUpdate(boolean update) {
156        this.update = update;
157    }
158
159}