1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <project name="mdrepo" xmlns:xdb="http://exist-db.org/ant" > |
---|
3 | |
---|
4 | |
---|
5 | <!-- |
---|
6 | two flags: |
---|
7 | skip.download |
---|
8 | skip.clean-target |
---|
9 | --> |
---|
10 | <property name="data.dir" value="data/cmdi-current"/> |
---|
11 | <property name="dataset" value="olac-and-dc-providers" /> |
---|
12 | <property name="target.server" value="localhost:8089/exist9"/> |
---|
13 | <property name="target.path" value="http://${target.server}/rest/db/mdrepo-data"/> |
---|
14 | <property name="target-xmldb.path" value="xmldb:exist://${target.server}/xmlrpc/db/mdrepo-data"/> |
---|
15 | |
---|
16 | <property file="build.props" /> |
---|
17 | |
---|
18 | <target name="init"> |
---|
19 | <mkdir dir="${data.dir}" /> |
---|
20 | <mkdir dir="${data.dir}/logs" /> |
---|
21 | <tstamp> |
---|
22 | <format property="start.time" pattern="yyyy-MM-dd HH:mm:ss" /> |
---|
23 | </tstamp> |
---|
24 | </target> |
---|
25 | |
---|
26 | <target name="download" depends="init" unless="skip.download"> |
---|
27 | <!-- <get usetimestamp="true" src="http://catalog.clarin.eu/oai-harvester/resultsets/cmdi-providers.tar.bz2" dest="${data.dir}/cmdi-providers.tar.bz2"/> |
---|
28 | <get usetimestamp="true" src="http://catalog.clarin.eu/oai-harvester/resultsets/mpi-self-harvest.tar.bz2" dest="${data.dir}/mpi-self-harvest.tar.bz2"/> |
---|
29 | --> |
---|
30 | <get usetimestamp="true" src="http://catalog.clarin.eu/oai-harvester/resultsets/${dataset}.tar.bz2" dest="${data.dir}/${dataset}.tar.bz2" |
---|
31 | /> |
---|
32 | |
---|
33 | </target> |
---|
34 | |
---|
35 | <target name="unzip" depends="download" unless="skip.download"> |
---|
36 | |
---|
37 | <!-- <bunzip2 src="${data.dir}/${dataset}.tar.bz2" dest="${data.dir}" /> --> |
---|
38 | <untar src="${data.dir}/${dataset}.tar.bz2" dest="${data.dir}/${dataset}" compression="bzip2"/> |
---|
39 | </target> |
---|
40 | |
---|
41 | <target name="upload" depends="unzip"> |
---|
42 | <!-- <target name="upload" depends="init"> --> |
---|
43 | <tstamp> |
---|
44 | <format property="start-upload.time" pattern="yyyy-MM-dd HH:mm:ss" /> |
---|
45 | </tstamp> |
---|
46 | <exec executable="./upload.sh"> |
---|
47 | <!-- <arg value="${data.dir}/${dataset}/results/cmdi/Academia_Sinica_Balanced_Corpus_of_Modern_Chinese/" /> --> |
---|
48 | <arg value="${data.dir}/${dataset}/results/cmdi" /> |
---|
49 | <arg value="${target.path}/${dataset}" /> |
---|
50 | <arg value="${user}" /> |
---|
51 | <arg value="${pwd}" /> |
---|
52 | <!-- -exec curl -i -H "Accept: application/xml" -u "cr-writer:pwd" -X PUT -T \{} http://localhost/exist9/rest/db/mdrepo-data/${dataset}/\{} \; > upload.log' /> --> |
---|
53 | </exec> |
---|
54 | <antcall target="log-import" /> |
---|
55 | </target> |
---|
56 | |
---|
57 | |
---|
58 | <target name="upload-xdb" depends="unzip, clean-target"> |
---|
59 | |
---|
60 | <!-- <antcall target="clean-target" /> --> |
---|
61 | |
---|
62 | <tstamp> |
---|
63 | <format property="start-upload.time" pattern="yyyy-MM-dd HH:mm:ss" /> |
---|
64 | </tstamp> |
---|
65 | |
---|
66 | <xdb:store xmlns:xdb="http://exist-db.org/ant" |
---|
67 | uri="${target-xmldb.path}/${dataset}" |
---|
68 | user="${user}" password="${pwd}" |
---|
69 | createcollection="true" |
---|
70 | createsubcollections="true" > |
---|
71 | <fileset dir="${data.dir}/${dataset}/results/cmdi"> |
---|
72 | </fileset> |
---|
73 | </xdb:store> |
---|
74 | <antcall target="log-import" /> |
---|
75 | |
---|
76 | </target> |
---|
77 | |
---|
78 | |
---|
79 | <target name="clean-target" unless="skip.clean-target" > |
---|
80 | <xdb:remove xmlns:xdb="http://exist-db.org/ant" user="${user}" password="${pwd}" |
---|
81 | uri="${target-xmldb.path}" collection="${dataset}" /> |
---|
82 | </target> |
---|
83 | |
---|
84 | <target name="clean" > |
---|
85 | <delete dir="${data.dir}" /> |
---|
86 | </target> |
---|
87 | |
---|
88 | |
---|
89 | <target name="backup-raw" > |
---|
90 | <echo>TODO</echo> |
---|
91 | |
---|
92 | </target> |
---|
93 | |
---|
94 | <target name="log-import" > |
---|
95 | |
---|
96 | <tstamp> |
---|
97 | <format property="file.time" pattern="yyyyMMdd-HHmmss-S" /> |
---|
98 | </tstamp> |
---|
99 | <tstamp> |
---|
100 | <format property="end.time" pattern="yyyy-MM-dd HH:mm:ss" /> |
---|
101 | </tstamp> |
---|
102 | |
---|
103 | <resourcecount property="count.files"> |
---|
104 | <fileset dir="${data.dir}/${dataset}/results/cmdi"> |
---|
105 | </fileset> |
---|
106 | </resourcecount> |
---|
107 | |
---|
108 | <property name="file.name" value="import-log-${dataset}-${file.time}.xml"/> |
---|
109 | <property name="file.path" value="${data.dir}/logs/${file.name}"/> |
---|
110 | |
---|
111 | <echoxml file="${file.path}"><log dataset="${dataset}" start-time="${start.time}" |
---|
112 | start-upload-time="${start-upload.time}" end-time="${end.time}" |
---|
113 | count-files="${count.files}" /> |
---|
114 | |
---|
115 | </echoxml> |
---|
116 | |
---|
117 | <echo>uploaded files: ${count.files}</echo> |
---|
118 | <echo>wrote import-log to ${file.path}</echo> |
---|
119 | <echo>start-time: ${start.time}</echo> |
---|
120 | <echo>end-time: ${end.time}</echo> |
---|
121 | |
---|
122 | <xdb:store xmlns:xdb="http://exist-db.org/ant" |
---|
123 | uri="${target-xmldb.path}/logs" |
---|
124 | user="${user}" password="${pwd}" |
---|
125 | createcollection="true" |
---|
126 | srcfile="${file.path}"/> |
---|
127 | <echo>uploaded import-log to ${target-xmldb.path}/logs/${file.name}</echo> |
---|
128 | |
---|
129 | </target> |
---|
130 | |
---|
131 | |
---|
132 | <property name="server.dir" value="/opt/exist-code"/> |
---|
133 | |
---|
134 | <path id="classpath.core"> |
---|
135 | <fileset dir="${server.dir}/lib/core"> |
---|
136 | <include name="*.jar"/> |
---|
137 | </fileset> |
---|
138 | <pathelement path="${server.dir}/exist.jar"/> |
---|
139 | <pathelement path="${server.dir}/exist-optional.jar"/> |
---|
140 | </path> |
---|
141 | |
---|
142 | <typedef resource="org/exist/ant/antlib.xml" uri="http://exist-db.org/ant"> |
---|
143 | <classpath refid="classpath.core"/> |
---|
144 | </typedef> |
---|
145 | |
---|
146 | </project> |
---|