diff options
Diffstat (limited to 'hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse')
9 files changed, 358 insertions, 0 deletions
diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ExportXMI.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ExportXMI.java new file mode 100755 index 000000000..4e829c4aa --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ExportXMI.java @@ -0,0 +1,49 @@ +/** + * <copyright> + * + * Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Taal + * </copyright> + * + * $Id: ExportXMI.java,v 1.3 2008/02/28 07:07:59 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.io.ByteArrayOutputStream; +import java.util.Properties; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.emf.teneo.eclipse.resourcehandler.StoreExportXML; +import org.eclipse.emf.teneo.hibernate.HbConstants; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.HbUtil; + +/** + * Performs the export xmi action + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.3 $ + */ + +public class ExportXMI extends StoreExportXML { + /** Can be overridden */ + protected boolean isXMLExport() { + return false; + } + + /** Does the real export */ + protected byte[] doExport(Properties props) { + HbDataStore emfds = HbUtil.getCreateDataStore(props); + // for now export the whole content to one byte array + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + emfds.exportDataStore(os, HbConstants.EXCHANGE_FORMAT_XMI, ResourcesPlugin.getEncoding()); + return os.toByteArray(); + } +} diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ExportXML.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ExportXML.java new file mode 100755 index 000000000..26168097d --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ExportXML.java @@ -0,0 +1,45 @@ +/** + * <copyright> + * + * Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Taal + * </copyright> + * + * $Id: ExportXML.java,v 1.3 2008/02/28 07:07:59 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.io.ByteArrayOutputStream; +import java.util.Properties; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.emf.teneo.eclipse.resourcehandler.StoreExportXML; +import org.eclipse.emf.teneo.hibernate.HbConstants; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.HbUtil; + +/** + * Performs the export xml action + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.3 $ + */ + +public class ExportXML extends StoreExportXML { + /** Does the real export */ + protected byte[] doExport(Properties props) { + HbDataStore emfds = HbUtil.getCreateDataStore(props); + // for now export the whole content to one byte array + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + emfds.exportDataStore(os, HbConstants.EXCHANGE_FORMAT_XML, ResourcesPlugin.getEncoding()); + return os.toByteArray(); + } + +} diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/GenerateHBMAction.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/GenerateHBMAction.java new file mode 100755 index 000000000..78e43e843 --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/GenerateHBMAction.java @@ -0,0 +1,39 @@ +/** + * <copyright> Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others All rights + * reserved. This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal </copyright> $Id: + * GenerateHBMAction.java,v 1.2 2007/02/01 12:34:24 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.util.HashMap; + +import org.eclipse.emf.teneo.PersistenceOptions; +import org.eclipse.emf.teneo.annotations.pannotation.InheritanceType; +import org.eclipse.emf.teneo.eclipse.genxml.GenerateMappingAction; +import org.eclipse.emf.teneo.hibernate.HbConstants; +import org.eclipse.emf.teneo.hibernate.mapper.GenerateHBM; +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.IActionDelegate; + +/** + * Eclipse popup action to generate a hibernate file based on ecore files. + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.6 $ + */ + +public class GenerateHBMAction extends GenerateMappingAction { + /** + * @see IActionDelegate#run(IAction) + */ + @Override + public void run(IAction action) { + final HashMap<String, String> options = new HashMap<String, String>(); + options.put(PersistenceOptions.INHERITANCE_MAPPING, InheritanceType.JOINED.getName()); + super.run(action, HbConstants.HBM_FILE_NAME, Messages.getString("teneo.generate.hbm"), options, + GenerateHBM.class.getName()); + } +}
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/GenerateHBMActionSuperClass.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/GenerateHBMActionSuperClass.java new file mode 100755 index 000000000..038ef4c6a --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/GenerateHBMActionSuperClass.java @@ -0,0 +1,39 @@ +/** + * <copyright> Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others All rights + * reserved. This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal </copyright> $Id: + * GenerateHBMActionSuperClass.java,v 1.2 2007/02/01 12:34:24 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.util.HashMap; + +import org.eclipse.emf.teneo.PersistenceOptions; +import org.eclipse.emf.teneo.annotations.pannotation.InheritanceType; +import org.eclipse.emf.teneo.eclipse.genxml.GenerateMappingAction; +import org.eclipse.emf.teneo.hibernate.HbConstants; +import org.eclipse.emf.teneo.hibernate.mapper.GenerateHBM; +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.IActionDelegate; + +/** + * Eclipse popup action to generate a hbm file based on the ecore files. + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.7 $ + */ + +public class GenerateHBMActionSuperClass extends GenerateMappingAction { + /** + * @see IActionDelegate#run(IAction) + */ + @Override + public void run(IAction action) { + final HashMap<String, String> options = new HashMap<String, String>(); + options.put(PersistenceOptions.INHERITANCE_MAPPING, InheritanceType.SINGLE_TABLE.getName()); + super.run(action, HbConstants.HBM_FILE_NAME, Messages.getString("teneo.generate.hbm"), options, + GenerateHBM.class.getName()); + } +}
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ImportXMI.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ImportXMI.java new file mode 100755 index 000000000..7d09c2122 --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ImportXMI.java @@ -0,0 +1,53 @@ +/** + * <copyright> Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others All rights + * reserved. This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal </copyright> $Id: + * ImportXMI.java,v 1.2 2007/02/01 12:34:24 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.teneo.eclipse.StoreEclipseException; +import org.eclipse.emf.teneo.eclipse.resourcehandler.StoreImportXML; +import org.eclipse.emf.teneo.hibernate.HbConstants; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.HbUtil; + +/** + * Performs the import xmi action + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.4 $ + */ + +public class ImportXMI extends StoreImportXML { + /** Can be overridden */ + @Override + protected boolean isXMLImport() { + return false; + } + + /** Imports the files into the store */ + @Override + protected void doImport(IFile[] files, Properties props) { + try { + final HbDataStore emfds = HbUtil.getCreateDataStore(props); + for (IFile element : files) { + final InputStream is = element.getContents(); + emfds.importDataStore(is, HbConstants.EXCHANGE_FORMAT_XMI); + is.close(); + } + } catch (IOException i) { + throw new StoreEclipseException("IO exception while importing xmi", i); + } catch (CoreException c) { + throw new StoreEclipseException("Core exception while importing xmi", c); + } + } +} diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ImportXML.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ImportXML.java new file mode 100755 index 000000000..ffb9c0876 --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/ImportXML.java @@ -0,0 +1,46 @@ +/** + * <copyright> Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others All rights + * reserved. This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal </copyright> $Id: + * ImportXML.java,v 1.3 2007/02/01 12:34:24 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.teneo.eclipse.StoreEclipseException; +import org.eclipse.emf.teneo.eclipse.resourcehandler.StoreImportXML; +import org.eclipse.emf.teneo.hibernate.HbConstants; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.HbUtil; + +/** + * Performs the import xml action + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.5 $ + */ + +public class ImportXML extends StoreImportXML { + /** Imports the files into the store */ + protected void doImport(IFile[] files, Properties props) { + try { + final HbDataStore emfds = HbUtil.getCreateDataStore(props); + for (int i = 0; i < files.length; i++) { + final InputStream is = files[i].getContents(); + emfds.importDataStore(is, HbConstants.EXCHANGE_FORMAT_XML); + is.close(); + } + } catch (IOException i) { + throw new StoreEclipseException("IO exception while importing xml", i); + } catch (CoreException c) { + throw new StoreEclipseException("Core exception while importing xml", c); + } + } +} diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/Messages.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/Messages.java new file mode 100644 index 000000000..4e6e82893 --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/Messages.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * @author Victor Roldan Betancort + */ +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.emf.teneo.hibernate.eclipse.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/OpenResource.java b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/OpenResource.java new file mode 100755 index 000000000..be6f9c91a --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/OpenResource.java @@ -0,0 +1,35 @@ +/** + * <copyright> + * + * Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Taal + * </copyright> + * + * $Id: OpenResource.java,v 1.3 2008/02/28 07:07:59 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.eclipse; + +import java.util.Properties; + +import org.eclipse.emf.teneo.eclipse.resourcehandler.StoreOpenResource; +import org.eclipse.emf.teneo.hibernate.HbUtil; + +/** + * Performs the open resource action based on the information in the .ehb file + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.3 $ + */ +public class OpenResource extends StoreOpenResource { + /** Ensure that the data store is opened */ + protected void openDataStore(Properties props) { + HbUtil.getCreateDataStore(props); + } +}
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/messages.properties b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/messages.properties new file mode 100644 index 000000000..b75dd5147 --- /dev/null +++ b/hibernate/org.eclipse.emf.teneo.hibernate.eclipse/src/org/eclipse/emf/teneo/hibernate/eclipse/messages.properties @@ -0,0 +1,17 @@ +# ============================================================================== +# Copyright (c) 2004 - 2009 Martin Taal and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Martin Taal +# ============================================================================== + +# ============================================================================== +# This properties file contains all strings subject to be shown in the UI. +# ============================================================================== + +teneo.generate.hbm.cdo = "Generate Hibernate mapping file for CDO +teneo.generate.hbm = Generate Hibernate mapping file
\ No newline at end of file |