1 package org.andromda.maven.plugin.andromdapp.hibernate;
2
3 import java.io.File;
4 import java.util.List;
5 import java.util.Map;
6 import java.util.Random;
7 import org.andromda.core.common.Constants;
8 import org.andromda.core.common.ResourceWriter;
9
10
11
12
13
14
15
16 public class HibernateValidateSchema
17 extends HibernateSchemaManagement
18 {
19 private static final String HIBERNATE_PROPERTIES_TEMP_DIRECTORY =
20 Constants.TEMPORARY_DIRECTORY + "andromdapp/hibernate-schema-validate";
21
22
23
24
25 protected String getExecutionClassName()
26 {
27 return "SchemaValidator";
28 }
29
30
31
32
33 protected String getExecutionOuputPath(final Map options)
34 {
35 return null;
36 }
37
38 private static final Random random = new Random();
39
40
41
42 protected void addArguments(final Map options, final List<String> arguments) throws Exception
43 {
44 final String driverClass = this.getRequiredProperty(
45 options,
46 "jdbcDriver");
47 final String connectionUrl = this.getRequiredProperty(
48 options,
49 "jdbcConnectionUrl");
50 final String username = this.getRequiredProperty(
51 options,
52 "jdbcUsername");
53 final String password = this.getRequiredProperty(
54 options,
55 "jdbcPassword");
56 final StringBuilder contents = new StringBuilder();
57 contents.append("hibernate.connection.driver_class=").append(driverClass).append('\n');
58 contents.append("hibernate.connection.url=").append(connectionUrl).append('\n');
59 contents.append("hibernate.connection.username=").append(username).append('\n');
60 contents.append("hibernate.connection.password=").append(password).append('\n');
61 final File temporaryProperitesFile =
62 new File(HIBERNATE_PROPERTIES_TEMP_DIRECTORY, String.valueOf(random.nextDouble()));
63 temporaryProperitesFile.deleteOnExit();
64 ResourceWriter.instance().writeStringToFile(
65 contents.toString(),
66 temporaryProperitesFile.toString());
67 arguments.add("--properties=" + temporaryProperitesFile);
68 }
69 }