001package org.andromda.maven.plugin.andromdapp.hibernate;
002
003import java.io.File;
004import java.util.List;
005import java.util.Map;
006
007/**
008 * Provides the ability to drop a schema from Hibernate
009 * mapping files.
010 *
011 * @author Chad Brandon
012 */
013public class HibernateDropSchema
014    extends HibernateSchemaManagement
015{
016    /**
017     * The drop output path.
018     */
019    private static final String DROP_OUTPUT_PATH = "dropOutputPath";
020
021    /**
022     * @see org.andromda.maven.plugin.andromdapp.hibernate.HibernateSchemaManagement#addArguments(Map, List)
023     */
024    protected void addArguments(
025        final Map options,
026        final List<String> arguments)
027    {
028        final String outputPath = this.getRequiredProperty(
029            options,
030            DROP_OUTPUT_PATH);
031        final File file = new File(outputPath);
032        final File parent = file.getParentFile();
033        if (parent != null)
034        {
035            parent.mkdirs();
036        }
037        arguments.add("--output=" + outputPath);
038        arguments.add("--text");
039        arguments.add("--quiet");
040        arguments.add("--drop");
041    }
042
043    /**
044     * @see org.andromda.maven.plugin.andromdapp.hibernate.HibernateSchemaManagement#getExecutionOuputPath(java.util.Map)
045     */
046    protected String getExecutionOuputPath(final Map options)
047    {
048        return this.getRequiredProperty(
049            options,
050            DROP_OUTPUT_PATH);
051    }
052
053    /**
054     * @see org.andromda.maven.plugin.andromdapp.hibernate.HibernateSchemaManagement#getExecutionClassName()
055     */
056    protected String getExecutionClassName()
057    {
058        return "SchemaExport";
059    }
060}