001/*
002 * (C) Copyright 2006-2012 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;
022import java.text.SimpleDateFormat;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026
027/**
028 * XMap descriptor for meta-data mapping
029 *
030 * @author Thierry Delprat
031 */
032@XObject("fieldMapping")
033public class ScanFileFieldMapping implements Serializable {
034
035    private static final long serialVersionUID = 1L;
036
037    public static final SimpleDateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'Z'");
038
039    @XNode("@sourceXPath")
040    protected String sourceXPath;
041
042    @XNode("@sourceAttribute")
043    protected String sourceAttribute = "TEXT";
044
045    @XNode("@targetXPath")
046    protected String targetXPath;
047
048    @XNode("@targetType")
049    protected String targetType = "String";
050
051    @XNode("@dateFormat")
052    protected String dateFormatStr;
053
054    protected SimpleDateFormat dateFormat;
055
056    public SimpleDateFormat getDateFormat() {
057        if (dateFormat == null) {
058            if (dateFormatStr != null) {
059                dateFormat = new SimpleDateFormat(dateFormatStr);
060            } else {
061                dateFormat = DEFAULT_DATE_FORMAT;
062            }
063        }
064        return dateFormat;
065    }
066
067    public String getSourceXPath() {
068        return sourceXPath;
069    }
070
071    public String getSourceAttribute() {
072        return sourceAttribute;
073    }
074
075    public String getTargetXPath() {
076        return targetXPath;
077    }
078
079    public String getTargetType() {
080        return targetType;
081    }
082
083}