/*******************************************************************************
 * Copyright (c) 2017 Inria
 * 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:
 *  - Faiez Zalila <faiez.zalila@inria.fr>
 *******************************************************************************/
package org.eclipse.cmf.occi.core.util;

/**
 * This class provides utility functions related to the mapping of OCCI to Ecore.
 * 
 * @author Faiez Zalila - Inria
 */
public class OCCI2Ecore
{
	/**
	 * Suffix added to the name space of EPackage.
	 */
	static final String ECORE_SUFFIX = "/ecore";

	/**
	 * This class can not be instantiated.
	 */
	private OCCI2Ecore()
	{
	}

	/**
	 * Converts an OCCI scheme to an Ecore name space.
	 * @param occiScheme the OCCI scheme.
	 * @return the Ecore name space.
	 */
	public static String convertOcciScheme2EcoreNamespace(final String occiScheme) {
		return occiScheme.substring(0, occiScheme.length()-1) + ECORE_SUFFIX;
	}

	/**
	 * Converts an Ecore name space to an OCCI scheme.
	 * @param ecoreNamespace the Ecore name space.
	 * @return the OCCI scheme.
	 */
	public static String convertEcoreNamespace2OcciScheme(final String ecoreNamespace) {
		return ecoreNamespace.substring(0, ecoreNamespace.length()-ECORE_SUFFIX.length()) + '#';
	}

	/**
	 * Converts an OCCI category term to an Ecore class name.
	 * @param term the OCCI category term.
	 * @return the Ecore class name.
	 */
	public static String convertOcciCategoryTerm2EcoreClassName(String term) {
		return term.substring(0,1).toUpperCase() + term.substring(1);
	}

	/**
	 * Convert an Ecore class name to an OCCI category term.
	 * @param eclassName the given Ecore class name.
	 * @return an OCCI category term.
	 */
	public static String convertEcoreClassName2OcciCategoryTerm(String eclassName)
	{
		return eclassName.substring(0, 1).toLowerCase() + eclassName.substring(1);
	}

	/**
	 * Convert an OCCI attribute name to an Ecore feature name.
	 * @param attributeName the given OCCI attribute name.
	 * @return the converted Ecore attribute name.
	 */
	public static String convertOcciAttributeName2EcoreAttributeName(final String attributeName)
	{
		int index = attributeName.lastIndexOf('.');
		return (index != -1) ? attributeName.substring(index+1) : attributeName;
	}
}

@@ -2365,76 +2365,242 @@
 %7B%0A%09%09
-int index = attributeName.lastIndexOf('.');%0A%09%09return (index != -1) ?
+String%5B%5D attributeNameArray = attributeName.split(%22%5C%5C.%22);%0A%09%09String newattribute= %22%22;%0A%09%09for(int i = 0; i %3C attributeNameArray.length; i++)%7B%0A%09%09%09%0A%09%09%09if(i == 0)%7B%0A%09%09%09%09newattribute += attributeNameArray%5B0%5D;%0A%09%09%09%7D%0A%09%09%09else%7B%0A%09%09%09%09newattribute +=
  att
@@ -2605,24 +2605,32 @@
 ttributeName
+Array%5Bi%5D
 .substring(i
@@ -2632,31 +2632,96 @@
 ing(
-index+1) : attributeNam
+0, 1).toUpperCase() + attributeNameArray%5Bi%5D.substring(1);;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return newattribut
 e;%0A%09

Fix this bug https://github.com/occiware/ecore/issues/96