Project

General

Profile

« Previous | Next » 

Revision c09572ee

Added by Patrick Plitzner about 8 years ago

minor

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/out/BfnXmlExport.java
1
/**
2
 * Copyright (C) 2008 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 */
6

  
7
package eu.etaxonomy.cdm.app.redlist.out;
8

  
9
import java.io.File;
10
import java.io.FileWriter;
11
import java.io.IOException;
12

  
13
import org.apache.log4j.Logger;
14
import org.jdom2.Document;
15
import org.jdom2.Element;
16
import org.jdom2.output.Format;
17
import org.jdom2.output.XMLOutputter;
18

  
19
import eu.etaxonomy.cdm.app.common.CdmDestinations;
20
import eu.etaxonomy.cdm.app.sdd.ViolaExportActivator;
21
import eu.etaxonomy.cdm.database.ICdmDataSource;
22
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
23
import eu.etaxonomy.cdm.io.redlist.bfnXml.BfnXmlConstants;
24
import eu.etaxonomy.cdm.io.redlist.bfnXml.out.BfnXmlExportConfigurator;
25
import eu.etaxonomy.cdm.io.redlist.bfnXml.out.BfnXmlExportTransformer;
26

  
27
/**
28
 *
29
 * @author pplitzner
30
 * @date May 3, 2016
31
 *
32
 */
33
public class BfnXmlExport {
34

  
35
	private static final Logger logger = Logger.getLogger(ViolaExportActivator.class);
36

  
37
    protected Document document;
38

  
39
	private void invokeExport(String[] args) {
40

  
41
		ICdmDataSource sourceDb = CdmDestinations.cdm_test_local_mysql();
42
		BfnXmlExportTransformer transformer = new BfnXmlExportTransformer();
43
		File destination = new File("/home/pplitzner/Rote Listen 2020/doctronic/export/export.xml");
44
        document = createDocument();
45
		BfnXmlExportConfigurator config = BfnXmlExportConfigurator.NewInstance(destination, sourceDb, transformer, document);
46

  
47
		CdmDefaultExport<BfnXmlExportConfigurator> export = new CdmDefaultExport<BfnXmlExportConfigurator>();
48

  
49
		// invoke export
50
		logger.debug("Invoking BfnXml export");
51
		export.invoke(config);
52

  
53
        outputXML(destination);
54

  
55
	}
56

  
57
    private void outputXML(File file) {
58
        XMLOutputter xml = new XMLOutputter();
59
        xml.setFormat(Format.getPrettyFormat());
60
        try {
61
            xml.output(document, new FileWriter(file));
62
        } catch (IOException e) {
63
            e.printStackTrace();
64
        }
65
    }
66

  
67
    private Document createDocument(){
68
        Document document = new Document();// create root element
69
        Element rootElement = new Element(BfnXmlConstants.EL_DEB_EXPORT);
70
        document.setRootElement(rootElement);
71
        return document;
72
    }
73

  
74
	public static void main(String[] args) {
75
		BfnXmlExport export = new BfnXmlExport();
76
		export.invokeExport(args);
77
	}
78

  
79
}
1
/**
2
 * Copyright (C) 2008 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 */
6

  
7
package eu.etaxonomy.cdm.app.redlist.out;
8

  
9
import java.io.File;
10
import java.io.FileWriter;
11
import java.io.IOException;
12

  
13
import org.apache.log4j.Logger;
14
import org.jdom2.Document;
15
import org.jdom2.Element;
16
import org.jdom2.output.Format;
17
import org.jdom2.output.XMLOutputter;
18

  
19
import eu.etaxonomy.cdm.app.common.CdmDestinations;
20
import eu.etaxonomy.cdm.app.sdd.ViolaExportActivator;
21
import eu.etaxonomy.cdm.database.ICdmDataSource;
22
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
23
import eu.etaxonomy.cdm.io.redlist.bfnXml.BfnXmlConstants;
24
import eu.etaxonomy.cdm.io.redlist.bfnXml.out.BfnXmlExportConfigurator;
25
import eu.etaxonomy.cdm.io.redlist.bfnXml.out.BfnXmlExportTransformer;
26

  
27
/**
28
 *
29
 * @author pplitzner
30
 * @date May 3, 2016
31
 *
32
 */
33
public class BfnXmlExport {
34

  
35
	private static final Logger logger = Logger.getLogger(ViolaExportActivator.class);
36

  
37
    protected Document document;
38

  
39
	private void invokeExport() {
40

  
41
		ICdmDataSource sourceDb = CdmDestinations.cdm_test_local_mysql();
42
		BfnXmlExportTransformer transformer = new BfnXmlExportTransformer();
43
		File destination = new File("/home/pplitzner/Rote Listen 2020/doctronic/export/export.xml");
44
        document = createDocument();
45
		BfnXmlExportConfigurator config = BfnXmlExportConfigurator.NewInstance(destination, sourceDb, transformer, document);
46

  
47
		CdmDefaultExport<BfnXmlExportConfigurator> export = new CdmDefaultExport<BfnXmlExportConfigurator>();
48

  
49
		// invoke export
50
		logger.debug("Invoking BfnXml export");
51
		export.invoke(config);
52

  
53
		logger.debug("Writing XML file");
54
        outputXML(destination);
55

  
56
	}
57

  
58
    private void outputXML(File file) {
59
        XMLOutputter xml = new XMLOutputter();
60
        xml.setFormat(Format.getPrettyFormat());
61
        try {
62
            xml.output(document, new FileWriter(file));
63
        } catch (IOException e) {
64
            e.printStackTrace();
65
        }
66
    }
67

  
68
    private Document createDocument(){
69
        Document document = new Document();// create root element
70
        Element rootElement = new Element(BfnXmlConstants.EL_DEB_EXPORT);
71
        document.setRootElement(rootElement);
72
        return document;
73
    }
74

  
75
	public static void main(String[] args) {
76
		BfnXmlExport export = new BfnXmlExport();
77
		export.invokeExport();
78
	}
79

  
80
}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlExportBase.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
11

  
12
import org.apache.log4j.Logger;
13

  
14
import eu.etaxonomy.cdm.io.common.CdmExportBase;
15
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17

  
18
/**
19
 *
20
 * @author pplitzner
21
 * @date May 3, 2016
22
 *
23
 * @param <T>
24
 */
25
public abstract class BfnXmlExportBase<T extends CdmBase> extends CdmExportBase<BfnXmlExportConfigurator, BfnXmlExportState, IExportTransformer> {
26

  
27
    private static final long serialVersionUID = 1115122553345412881L;
28

  
29
    private static final Logger logger = Logger.getLogger(BfnXmlExportBase.class);
30

  
31
	public BfnXmlExportBase() {
32
		super();
33
	}
34
}
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
11

  
12
import org.apache.log4j.Logger;
13

  
14
import eu.etaxonomy.cdm.io.common.CdmExportBase;
15
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17

  
18
/**
19
 *
20
 * @author pplitzner
21
 * @date May 3, 2016
22
 *
23
 * @param <T>
24
 */
25
public abstract class BfnXmlExportBase<T extends CdmBase> extends CdmExportBase<BfnXmlExportConfigurator, BfnXmlExportState, IExportTransformer> {
26

  
27
    private static final long serialVersionUID = 1115122553345412881L;
28

  
29
    private static final Logger logger = Logger.getLogger(BfnXmlExportBase.class);
30

  
31
	public BfnXmlExportBase() {
32
		super();
33
	}
34
}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlExportConfigurator.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
11

  
12
import java.io.File;
13

  
14
import org.apache.log4j.Logger;
15
import org.jdom2.Document;
16

  
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.XmlExportConfiguratorBase;
19
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
20

  
21
/**
22
 *
23
 * @author pplitzner
24
 * @date May 3, 2016
25
 *
26
 */
27
public class BfnXmlExportConfigurator extends XmlExportConfiguratorBase<BfnXmlExportState>{
28

  
29
    private static final long serialVersionUID = -74469857806841119L;
30

  
31
    @SuppressWarnings("unused")
32
	private static Logger logger = Logger.getLogger(BfnXmlExportConfigurator.class);
33

  
34
    private final Document document;
35

  
36
	public static BfnXmlExportConfigurator NewInstance(File destination, ICdmDataSource cdmSource, IExportTransformer transformer, Document document){
37
			return new BfnXmlExportConfigurator(destination, cdmSource, transformer, document);
38
	}
39

  
40
	private BfnXmlExportConfigurator(File destination, ICdmDataSource cdmSource, IExportTransformer transformer, Document document) {
41
	    super(destination, cdmSource, transformer);
42
	    this.document = document;
43
	}
44

  
45
	@Override
46
    protected void makeIoClassList(){
47
		ioClassList = new Class[]{
48
				BfnXmlTaxonNameExport.class
49
		};
50

  
51
	}
52

  
53
	@Override
54
    public BfnXmlExportState getNewState() {
55
		return new BfnXmlExportState(this);
56
	}
57

  
58
    public Document getDocument() {
59
        return document;
60
    }
61

  
62
}
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
11

  
12
import java.io.File;
13

  
14
import org.apache.log4j.Logger;
15
import org.jdom2.Document;
16

  
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.XmlExportConfiguratorBase;
19
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
20

  
21
/**
22
 *
23
 * @author pplitzner
24
 * @date May 3, 2016
25
 *
26
 */
27
public class BfnXmlExportConfigurator extends XmlExportConfiguratorBase<BfnXmlExportState>{
28

  
29
    private static final long serialVersionUID = -74469857806841119L;
30

  
31
    @SuppressWarnings("unused")
32
	private static Logger logger = Logger.getLogger(BfnXmlExportConfigurator.class);
33

  
34
    private final Document document;
35

  
36
	public static BfnXmlExportConfigurator NewInstance(File destination, ICdmDataSource cdmSource, IExportTransformer transformer, Document document){
37
			return new BfnXmlExportConfigurator(destination, cdmSource, transformer, document);
38
	}
39

  
40
	private BfnXmlExportConfigurator(File destination, ICdmDataSource cdmSource, IExportTransformer transformer, Document document) {
41
	    super(destination, cdmSource, transformer);
42
	    this.document = document;
43
	}
44

  
45
	@Override
46
    protected void makeIoClassList(){
47
		ioClassList = new Class[]{
48
				BfnXmlTaxonNameExport.class
49
		};
50

  
51
	}
52

  
53
	@Override
54
    public BfnXmlExportState getNewState() {
55
		return new BfnXmlExportState(this);
56
	}
57

  
58
    public Document getDocument() {
59
        return document;
60
    }
61

  
62
}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlExportState.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
12

  
13
import org.apache.log4j.Logger;
14

  
15
import eu.etaxonomy.cdm.io.common.XmlExportState;
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @date May 3, 2016
21
 *
22
 */
23
public class BfnXmlExportState extends XmlExportState<BfnXmlExportConfigurator>{
24

  
25
	@SuppressWarnings("unused")
26
	private static final Logger logger = Logger.getLogger(BfnXmlExportState.class);
27

  
28
	public BfnXmlExportState(BfnXmlExportConfigurator config) {
29
		super(config);
30
	}
31

  
32
}
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
12

  
13
import org.apache.log4j.Logger;
14

  
15
import eu.etaxonomy.cdm.io.common.XmlExportState;
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @date May 3, 2016
21
 *
22
 */
23
public class BfnXmlExportState extends XmlExportState<BfnXmlExportConfigurator>{
24

  
25
	@SuppressWarnings("unused")
26
	private static final Logger logger = Logger.getLogger(BfnXmlExportState.class);
27

  
28
	public BfnXmlExportState(BfnXmlExportConfigurator config) {
29
		super(config);
30
	}
31

  
32
}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlTaxonNameExport.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
10

  
11
import org.apache.log4j.Logger;
12
import org.springframework.stereotype.Component;
13

  
14
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
15

  
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @date May 3, 2016
21
 *
22
 */
23
@Component
24
public class BfnXmlTaxonNameExport extends BfnXmlExportBase<TaxonNameBase> {
25

  
26
    private static final long serialVersionUID = -931703660108981011L;
27

  
28
    private static final Logger logger = Logger.getLogger(BfnXmlTaxonNameExport.class);
29

  
30
	public BfnXmlTaxonNameExport(){
31
		super();
32
	}
33

  
34
	@Override
35
    protected void doInvoke(BfnXmlExportState state){
36
	}
37

  
38
    @Override
39
    protected boolean doCheck(BfnXmlExportState state) {
40
        return false;
41
    }
42

  
43
    @Override
44
    protected boolean isIgnore(BfnXmlExportState state) {
45
        return false;
46
    }
47

  
48
}
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
10

  
11
import org.apache.log4j.Logger;
12
import org.springframework.stereotype.Component;
13

  
14
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
15

  
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @date May 3, 2016
21
 *
22
 */
23
@Component
24
public class BfnXmlTaxonNameExport extends BfnXmlExportBase<TaxonNameBase> {
25

  
26
    private static final long serialVersionUID = -931703660108981011L;
27

  
28
    private static final Logger logger = Logger.getLogger(BfnXmlTaxonNameExport.class);
29

  
30
	public BfnXmlTaxonNameExport(){
31
		super();
32
	}
33

  
34
	@Override
35
    protected void doInvoke(BfnXmlExportState state){
36
	}
37

  
38
    @Override
39
    protected boolean doCheck(BfnXmlExportState state) {
40
        return false;
41
    }
42

  
43
    @Override
44
    protected boolean isIgnore(BfnXmlExportState state) {
45
        return false;
46
    }
47

  
48
}

Also available in: Unified diff