diff --git a/BimServer/generated/org/bimserver/tools/generators/AdaptorGenerator.java b/BimServer/generated/org/bimserver/tools/generators/AdaptorGenerator.java index 6ed9482226..ec7abed450 100644 --- a/BimServer/generated/org/bimserver/tools/generators/AdaptorGenerator.java +++ b/BimServer/generated/org/bimserver/tools/generators/AdaptorGenerator.java @@ -1,100 +1,100 @@ -package org.bimserver.tools.generators; - -import org.bimserver.shared.meta.*; -import org.bimserver.utils.*; -import java.io.File; - -public class AdaptorGenerator -{ - protected static String nl; - public static synchronized AdaptorGenerator create(String lineSeparator) - { - nl = lineSeparator; - AdaptorGenerator result = new AdaptorGenerator(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package org.bimserver.shared.interfaces;" + NL; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL + "import org.bimserver.shared.exceptions.UserException;" + NL + "import org.bimserver.shared.exceptions.ServerException;"; - protected final String TEXT_4 = NL + NL + "public class "; - protected final String TEXT_5 = "Adaptor implements "; - protected final String TEXT_6 = " {" + NL; - protected final String TEXT_7 = NL + "\tpublic "; - protected final String TEXT_8 = " "; - protected final String TEXT_9 = "("; - protected final String TEXT_10 = " "; - protected final String TEXT_11 = ") throws UserException, ServerException {"; - protected final String TEXT_12 = NL + "\t\treturn null;"; - protected final String TEXT_13 = NL + "\t}" + NL + "\t"; - protected final String TEXT_14 = NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(TEXT_1); - -/****************************************************************************** - * Copyright (C) 2009-2012 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - - stringBuffer.append(TEXT_2); - stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); - stringBuffer.append(TEXT_3); - -SService sService = (SService)argument; - - stringBuffer.append(TEXT_4); - stringBuffer.append(sService.getSimpleName()); - stringBuffer.append(TEXT_5); - stringBuffer.append(sService.getInterfaceClass().getName()); - stringBuffer.append(TEXT_6); - -for (SMethod method : sService.getMethods()) { - - stringBuffer.append(TEXT_7); - stringBuffer.append(method.getGenericReturnType() != null ? (method.getReturnType().toJavaCode() + "<" + method.getGenericReturnType().toJavaCode() + ">") : method.getReturnType().toJavaCode()); - stringBuffer.append(TEXT_8); - stringBuffer.append(method.getName()); - stringBuffer.append(TEXT_9); - - for (SParameter parameter : method.getParameters()) { - - stringBuffer.append(parameter.getGenericType() != null ? (parameter.getType().toJavaCode() + "<" + parameter.getGenericType() + ">") : parameter.getType().toJavaCode()); - stringBuffer.append(TEXT_10); - stringBuffer.append(parameter.getName()); - stringBuffer.append(parameter.isLast() ? "" : ", "); - - } - - stringBuffer.append(TEXT_11); - -if (!method.getReturnType().isVoid()) { - - stringBuffer.append(TEXT_12); - -} - - stringBuffer.append(TEXT_13); - -} - - stringBuffer.append(TEXT_14); - return stringBuffer.toString(); - } -} +package org.bimserver.tools.generators; + +import org.bimserver.shared.meta.*; +import org.bimserver.utils.*; +import java.io.File; + +public class AdaptorGenerator +{ + protected static String nl; + public static synchronized AdaptorGenerator create(String lineSeparator) + { + nl = lineSeparator; + AdaptorGenerator result = new AdaptorGenerator(); + nl = null; + return result; + } + + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = "package org.bimserver.shared.interfaces;" + NL; + protected final String TEXT_2 = NL; + protected final String TEXT_3 = NL + "import org.bimserver.shared.exceptions.UserException;" + NL + "import org.bimserver.shared.exceptions.ServerException;"; + protected final String TEXT_4 = NL + NL + "public class "; + protected final String TEXT_5 = "Adaptor implements "; + protected final String TEXT_6 = " {" + NL; + protected final String TEXT_7 = NL + "\tpublic "; + protected final String TEXT_8 = " "; + protected final String TEXT_9 = "("; + protected final String TEXT_10 = " "; + protected final String TEXT_11 = ") throws UserException, ServerException {"; + protected final String TEXT_12 = NL + "\t\treturn null;"; + protected final String TEXT_13 = NL + "\t}" + NL + "\t"; + protected final String TEXT_14 = NL + "}"; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(TEXT_1); + +/****************************************************************************** + * Copyright (C) 2009-2012 BIMserver.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + *****************************************************************************/ + + stringBuffer.append(TEXT_2); + stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); + stringBuffer.append(TEXT_3); + +SService sService = (SService)argument; + + stringBuffer.append(TEXT_4); + stringBuffer.append(sService.getSimpleName()); + stringBuffer.append(TEXT_5); + stringBuffer.append(sService.getInterfaceClass().getName()); + stringBuffer.append(TEXT_6); + +for (SMethod method : sService.getMethods()) { + + stringBuffer.append(TEXT_7); + stringBuffer.append(method.getGenericReturnType() != null ? (method.getReturnType().toJavaCode() + "<" + method.getGenericReturnType().toJavaCode() + ">") : method.getReturnType().toJavaCode()); + stringBuffer.append(TEXT_8); + stringBuffer.append(method.getName()); + stringBuffer.append(TEXT_9); + + for (SParameter parameter : method.getParameters()) { + + stringBuffer.append(parameter.getGenericType() != null ? (parameter.getType().toJavaCode() + "<" + parameter.getGenericType() + ">") : parameter.getType().toJavaCode()); + stringBuffer.append(TEXT_10); + stringBuffer.append(parameter.getName()); + stringBuffer.append(parameter.isLast() ? "" : ", "); + + } + + stringBuffer.append(TEXT_11); + +if (!method.getReturnType().isVoid()) { + + stringBuffer.append(TEXT_12); + +} + + stringBuffer.append(TEXT_13); + +} + + stringBuffer.append(TEXT_14); + return stringBuffer.toString(); + } +} diff --git a/BimServer/generated/org/bimserver/tools/generators/AsyncServiceGenerator.java b/BimServer/generated/org/bimserver/tools/generators/AsyncServiceGenerator.java index a1d53de816..1c321c25f6 100644 --- a/BimServer/generated/org/bimserver/tools/generators/AsyncServiceGenerator.java +++ b/BimServer/generated/org/bimserver/tools/generators/AsyncServiceGenerator.java @@ -1,157 +1,157 @@ -package org.bimserver.tools.generators; - -import org.bimserver.shared.meta.*; -import org.bimserver.utils.*; -import java.io.File; - -public class AsyncServiceGenerator -{ - protected static String nl; - public static synchronized AsyncServiceGenerator create(String lineSeparator) - { - nl = lineSeparator; - AsyncServiceGenerator result = new AsyncServiceGenerator(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package org.bimserver.shared.interfaces.async;" + NL; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL + "import java.util.concurrent.ExecutorService;"; - protected final String TEXT_4 = NL + "import "; - protected final String TEXT_5 = ";" + NL + "" + NL + "public class Async"; - protected final String TEXT_6 = " {" + NL + "" + NL + "\tprivate final ExecutorService executorService;" + NL + "\tprivate final "; - protected final String TEXT_7 = " syncService;" + NL + "" + NL + "\tpublic Async"; - protected final String TEXT_8 = "("; - protected final String TEXT_9 = " syncService, ExecutorService executorService) {" + NL + "\t\tthis.executorService = executorService;" + NL + "\t\tthis.syncService = syncService;" + NL + "\t}" + NL; - protected final String TEXT_10 = NL + "\tpublic interface "; - protected final String TEXT_11 = "Callback {" + NL + "\t\tvoid success("; - protected final String TEXT_12 = ");" + NL + "\t\tvoid error(Throwable e);" + NL + "\t}" + NL + "\t"; - protected final String TEXT_13 = NL + NL; - protected final String TEXT_14 = NL + "\tpublic void "; - protected final String TEXT_15 = "("; - protected final String TEXT_16 = "final "; - protected final String TEXT_17 = " "; - protected final String TEXT_18 = ", "; - protected final String TEXT_19 = "final "; - protected final String TEXT_20 = "Callback callback) {" + NL + "\t\texecutorService.submit(new Runnable(){" + NL + "\t\t\tpublic void run(){" + NL + "\t\t\t\ttry {"; - protected final String TEXT_21 = NL + "\t\t\t\t\tsyncService."; - protected final String TEXT_22 = "("; - protected final String TEXT_23 = ");" + NL + "\t\t\t\t\tcallback.success();" + NL + "\t\t\t\t"; - protected final String TEXT_24 = NL + "\t\t\t\t\tcallback.success(syncService."; - protected final String TEXT_25 = "("; - protected final String TEXT_26 = "));" + NL + "\t\t\t\t"; - protected final String TEXT_27 = "} catch (Throwable e) {" + NL + "\t\t\t\t\tcallback.error(e);" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t});" + NL + "\t}" + NL + "\t"; - protected final String TEXT_28 = NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(TEXT_1); - -/****************************************************************************** - * Copyright (C) 2009-2012 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - - stringBuffer.append(TEXT_2); - stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); - stringBuffer.append(TEXT_3); - -SService sService = (SService)argument; - - stringBuffer.append(TEXT_4); - stringBuffer.append(sService.getInterfaceClass().getName()); - stringBuffer.append(TEXT_5); - stringBuffer.append(sService.getInterfaceClass().getSimpleName()); - stringBuffer.append(TEXT_6); - stringBuffer.append(sService.getInterfaceClass().getSimpleName()); - stringBuffer.append(TEXT_7); - stringBuffer.append(sService.getInterfaceClass().getSimpleName()); - stringBuffer.append(TEXT_8); - stringBuffer.append(sService.getInterfaceClass().getSimpleName()); - stringBuffer.append(TEXT_9); - -for (SMethod method : sService.getMethods()) { - - stringBuffer.append(TEXT_10); - stringBuffer.append(StringUtils.firstUpperCase(method.getName())); - stringBuffer.append(TEXT_11); - stringBuffer.append(method.getReturnType().isVoid() ? "" : (method.returnTypeToJavaCode() + " result")); - stringBuffer.append(TEXT_12); - -} - - stringBuffer.append(TEXT_13); - -for (SMethod method : sService.getMethods()) { - - stringBuffer.append(TEXT_14); - stringBuffer.append(method.getName()); - stringBuffer.append(TEXT_15); - - for (SParameter parameter : method.getParameters()) { - - stringBuffer.append(TEXT_16); - stringBuffer.append(parameter.getGenericType() != null ? (parameter.getType().toJavaCode() + "<" + parameter.getGenericType() + ">") : parameter.getType().toJavaCode()); - stringBuffer.append(TEXT_17); - stringBuffer.append(parameter.getName()); - stringBuffer.append(TEXT_18); - - } - - stringBuffer.append(TEXT_19); - stringBuffer.append(StringUtils.firstUpperCase(method.getName())); - stringBuffer.append(TEXT_20); - if (method.getReturnType().isVoid()) { - stringBuffer.append(TEXT_21); - stringBuffer.append(method.getName()); - stringBuffer.append(TEXT_22); - - for (SParameter sParameter : method.getParameters()) { - - stringBuffer.append(sParameter.getName()); - stringBuffer.append(sParameter.isLast() ? "" : ", "); - - } - - stringBuffer.append(TEXT_23); - - } else { - - stringBuffer.append(TEXT_24); - stringBuffer.append(method.getName()); - stringBuffer.append(TEXT_25); - - for (SParameter sParameter : method.getParameters()) { - - stringBuffer.append(sParameter.getName()); - stringBuffer.append(sParameter.isLast() ? "" : ", "); - - } - - stringBuffer.append(TEXT_26); - - } - - stringBuffer.append(TEXT_27); - -} - - stringBuffer.append(TEXT_28); - return stringBuffer.toString(); - } -} +package org.bimserver.tools.generators; + +import org.bimserver.shared.meta.*; +import org.bimserver.utils.*; +import java.io.File; + +public class AsyncServiceGenerator +{ + protected static String nl; + public static synchronized AsyncServiceGenerator create(String lineSeparator) + { + nl = lineSeparator; + AsyncServiceGenerator result = new AsyncServiceGenerator(); + nl = null; + return result; + } + + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = "package org.bimserver.shared.interfaces.async;" + NL; + protected final String TEXT_2 = NL; + protected final String TEXT_3 = NL + "import java.util.concurrent.ExecutorService;"; + protected final String TEXT_4 = NL + "import "; + protected final String TEXT_5 = ";" + NL + "" + NL + "public class Async"; + protected final String TEXT_6 = " {" + NL + "" + NL + "\tprivate final ExecutorService executorService;" + NL + "\tprivate final "; + protected final String TEXT_7 = " syncService;" + NL + "" + NL + "\tpublic Async"; + protected final String TEXT_8 = "("; + protected final String TEXT_9 = " syncService, ExecutorService executorService) {" + NL + "\t\tthis.executorService = executorService;" + NL + "\t\tthis.syncService = syncService;" + NL + "\t}" + NL; + protected final String TEXT_10 = NL + "\tpublic interface "; + protected final String TEXT_11 = "Callback {" + NL + "\t\tvoid success("; + protected final String TEXT_12 = ");" + NL + "\t\tvoid error(Throwable e);" + NL + "\t}" + NL + "\t"; + protected final String TEXT_13 = NL + NL; + protected final String TEXT_14 = NL + "\tpublic void "; + protected final String TEXT_15 = "("; + protected final String TEXT_16 = "final "; + protected final String TEXT_17 = " "; + protected final String TEXT_18 = ", "; + protected final String TEXT_19 = "final "; + protected final String TEXT_20 = "Callback callback) {" + NL + "\t\texecutorService.submit(new Runnable(){" + NL + "\t\t\tpublic void run(){" + NL + "\t\t\t\ttry {"; + protected final String TEXT_21 = NL + "\t\t\t\t\tsyncService."; + protected final String TEXT_22 = "("; + protected final String TEXT_23 = ");" + NL + "\t\t\t\t\tcallback.success();" + NL + "\t\t\t\t"; + protected final String TEXT_24 = NL + "\t\t\t\t\tcallback.success(syncService."; + protected final String TEXT_25 = "("; + protected final String TEXT_26 = "));" + NL + "\t\t\t\t"; + protected final String TEXT_27 = "} catch (Throwable e) {" + NL + "\t\t\t\t\tcallback.error(e);" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t});" + NL + "\t}" + NL + "\t"; + protected final String TEXT_28 = NL + "}"; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(TEXT_1); + +/****************************************************************************** + * Copyright (C) 2009-2012 BIMserver.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + *****************************************************************************/ + + stringBuffer.append(TEXT_2); + stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); + stringBuffer.append(TEXT_3); + +SService sService = (SService)argument; + + stringBuffer.append(TEXT_4); + stringBuffer.append(sService.getInterfaceClass().getName()); + stringBuffer.append(TEXT_5); + stringBuffer.append(sService.getInterfaceClass().getSimpleName()); + stringBuffer.append(TEXT_6); + stringBuffer.append(sService.getInterfaceClass().getSimpleName()); + stringBuffer.append(TEXT_7); + stringBuffer.append(sService.getInterfaceClass().getSimpleName()); + stringBuffer.append(TEXT_8); + stringBuffer.append(sService.getInterfaceClass().getSimpleName()); + stringBuffer.append(TEXT_9); + +for (SMethod method : sService.getMethods()) { + + stringBuffer.append(TEXT_10); + stringBuffer.append(StringUtils.firstUpperCase(method.getName())); + stringBuffer.append(TEXT_11); + stringBuffer.append(method.getReturnType().isVoid() ? "" : (method.returnTypeToJavaCode() + " result")); + stringBuffer.append(TEXT_12); + +} + + stringBuffer.append(TEXT_13); + +for (SMethod method : sService.getMethods()) { + + stringBuffer.append(TEXT_14); + stringBuffer.append(method.getName()); + stringBuffer.append(TEXT_15); + + for (SParameter parameter : method.getParameters()) { + + stringBuffer.append(TEXT_16); + stringBuffer.append(parameter.getGenericType() != null ? (parameter.getType().toJavaCode() + "<" + parameter.getGenericType() + ">") : parameter.getType().toJavaCode()); + stringBuffer.append(TEXT_17); + stringBuffer.append(parameter.getName()); + stringBuffer.append(TEXT_18); + + } + + stringBuffer.append(TEXT_19); + stringBuffer.append(StringUtils.firstUpperCase(method.getName())); + stringBuffer.append(TEXT_20); + if (method.getReturnType().isVoid()) { + stringBuffer.append(TEXT_21); + stringBuffer.append(method.getName()); + stringBuffer.append(TEXT_22); + + for (SParameter sParameter : method.getParameters()) { + + stringBuffer.append(sParameter.getName()); + stringBuffer.append(sParameter.isLast() ? "" : ", "); + + } + + stringBuffer.append(TEXT_23); + + } else { + + stringBuffer.append(TEXT_24); + stringBuffer.append(method.getName()); + stringBuffer.append(TEXT_25); + + for (SParameter sParameter : method.getParameters()) { + + stringBuffer.append(sParameter.getName()); + stringBuffer.append(sParameter.isLast() ? "" : ", "); + + } + + stringBuffer.append(TEXT_26); + + } + + stringBuffer.append(TEXT_27); + +} + + stringBuffer.append(TEXT_28); + return stringBuffer.toString(); + } +} diff --git a/BimServer/generated/org/bimserver/tools/generators/SConverterGenerator.java b/BimServer/generated/org/bimserver/tools/generators/SConverterGenerator.java index c8c7fbbe08..e93281cc13 100644 --- a/BimServer/generated/org/bimserver/tools/generators/SConverterGenerator.java +++ b/BimServer/generated/org/bimserver/tools/generators/SConverterGenerator.java @@ -1,542 +1,542 @@ -package org.bimserver.tools.generators; - -import org.eclipse.emf.ecore.*; -import org.bimserver.utils.*; -import org.bimserver.emf.MetaDataManager; -import java.io.File; -import java.util.Set; -import org.bimserver.utils.StringUtils; - -public class SConverterGenerator -{ - protected static String nl; - public static synchronized SConverterGenerator create(String lineSeparator) - { - nl = lineSeparator; - SConverterGenerator result = new SConverterGenerator(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package org.bimserver.interfaces;"; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = NL + NL + "import org.bimserver.emf.IdEObjectImpl;" + NL + "import org.bimserver.interfaces.objects.*;" + NL + "import java.util.*;" + NL + "import org.bimserver.models.log.*;" + NL + "import org.bimserver.models.store.*;" + NL + "import org.bimserver.database.DatabaseSession;" + NL + "import org.bimserver.database.BimserverDatabaseException;" + NL + "import org.bimserver.database.Query;" + NL + "" + NL + "public class SConverter {"; - protected final String TEXT_5 = NL + NL + "\tpublic Set list"; - protected final String TEXT_60 = " = new ArrayList();" + NL + "\t\tfor ("; - protected final String TEXT_61 = " v : input.get"; - protected final String TEXT_62 = "()) {" + NL + "\t\t\tlist"; - protected final String TEXT_63 = ".add(v.getOid());" + NL + "\t\t}" + NL + "\t\tresult.set"; - protected final String TEXT_64 = "(list"; - protected final String TEXT_65 = ");"; - protected final String TEXT_66 = NL + "\t\t"; - protected final String TEXT_67 = " "; - protected final String TEXT_68 = "Val = input.get"; - protected final String TEXT_69 = "();" + NL + "\t\tresult.set"; - protected final String TEXT_70 = "(convertToSObject("; - protected final String TEXT_71 = "Val));"; - protected final String TEXT_72 = NL + "\t\t"; - protected final String TEXT_73 = " "; - protected final String TEXT_74 = "Val = input.get"; - protected final String TEXT_75 = "();" + NL + "\t\tresult.set"; - protected final String TEXT_76 = "Id("; - protected final String TEXT_77 = "Val == null ? -1 : "; - protected final String TEXT_78 = "Val.getOid());"; - protected final String TEXT_79 = NL + "\t\treturn result;" + NL + "\t}" + NL + "\tpublic "; - protected final String TEXT_80 = " convertFromSObject(S"; - protected final String TEXT_81 = " input, DatabaseSession session) throws BimserverDatabaseException {" + NL + "\t\t"; - protected final String TEXT_82 = " result = convertFromSObject(input, "; - protected final String TEXT_83 = "Factory.eINSTANCE.create"; - protected final String TEXT_84 = "(), session);" + NL + "\t\t"; - protected final String TEXT_85 = NL + "\t\t((IdEObjectImpl)result).setOid(input.getOid());" + NL + "\t\t((IdEObjectImpl)result).setRid(input.getRid());" + NL + "\t\t"; - protected final String TEXT_86 = NL + "\t\treturn result;" + NL + "\t}" + NL + "" + NL + "\tpublic "; - protected final String TEXT_87 = " convertFromSObject(S"; - protected final String TEXT_88 = " input, "; - protected final String TEXT_89 = " result, DatabaseSession session) throws BimserverDatabaseException {" + NL + "\t\tif (input == null) {" + NL + "\t\t\treturn null;" + NL + "\t\t}"; - protected final String TEXT_90 = NL + "\t\t"; - protected final String TEXT_91 = "if (input instanceof S"; - protected final String TEXT_92 = ") {" + NL + "\t\t\treturn convertFromSObject((S"; - protected final String TEXT_93 = ")input, session);" + NL + "\t\t}"; - protected final String TEXT_94 = NL + "\t\tresult.set"; - protected final String TEXT_95 = "("; - protected final String TEXT_96 = ".values()[input.get"; - protected final String TEXT_97 = "().ordinal()]);"; - protected final String TEXT_98 = NL + "\t\tresult.get"; - protected final String TEXT_99 = "().addAll(input."; - protected final String TEXT_100 = "());"; - protected final String TEXT_101 = NL + "\t\tresult.set"; - protected final String TEXT_102 = "(input."; - protected final String TEXT_103 = "());"; - protected final String TEXT_104 = NL + "\t\tList<"; - protected final String TEXT_105 = "> list"; - protected final String TEXT_106 = " = result.get"; - protected final String TEXT_107 = "();" + NL + "\t\tfor (S"; - protected final String TEXT_108 = " v : input.get"; - protected final String TEXT_109 = "()) {" + NL + "\t\t\tlist"; - protected final String TEXT_110 = ".add(convertFromSObject(v, session));" + NL + "\t\t}"; - protected final String TEXT_111 = NL + "\t\tList<"; - protected final String TEXT_112 = "> list"; - protected final String TEXT_113 = " = result.get"; - protected final String TEXT_114 = "();" + NL + "\t\tfor (long oid : input.get"; - protected final String TEXT_115 = "()) {" + NL + "\t\t\tlist"; - protected final String TEXT_116 = ".add(("; - protected final String TEXT_117 = ")session.get("; - protected final String TEXT_118 = "Package.eINSTANCE.get"; - protected final String TEXT_119 = "(), oid, Query.getDefault()));" + NL + "\t\t}"; - protected final String TEXT_120 = NL + "\t\tresult.set"; - protected final String TEXT_121 = "(convertFromSObject(input.get"; - protected final String TEXT_122 = "(), session));"; - protected final String TEXT_123 = NL + "\t\tresult.set"; - protected final String TEXT_124 = "(("; - protected final String TEXT_125 = ")session.get("; - protected final String TEXT_126 = "Package.eINSTANCE.get"; - protected final String TEXT_127 = "(), input.get"; - protected final String TEXT_128 = "Id(), Query.getDefault()));"; - protected final String TEXT_129 = NL + "\t\treturn result;" + NL + "\t}"; - protected final String TEXT_130 = NL + "\t\tpublic S"; - protected final String TEXT_131 = " convertToSObject("; - protected final String TEXT_132 = " input) {" + NL + "\t\t\treturn S"; - protected final String TEXT_133 = ".values()[input.ordinal()];" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\tpublic "; - protected final String TEXT_134 = " convertFromSObject(S"; - protected final String TEXT_135 = " input) {" + NL + "\t\t\treturn "; - protected final String TEXT_136 = ".values()[input.ordinal()];" + NL + "\t\t}"; - protected final String TEXT_137 = NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(TEXT_1); - -/****************************************************************************** - * Copyright (C) 2009-2012 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); - stringBuffer.append(TEXT_4); - - try { - Object[] argumentsArray = (Object[])argument; - MetaDataManager metaDataManager = (MetaDataManager)argumentsArray[0]; - @SuppressWarnings("unchecked") Set ePackages = (Set)argumentsArray[1]; - for (EPackage ePackage : ePackages) { - for (EClassifier eClassifier : ePackage.getEClassifiers()) { - if (eClassifier instanceof EClass) { - EClass eClass = (EClass)eClassifier; - - stringBuffer.append(TEXT_5); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_6); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_7); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_8); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_9); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_10); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_11); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_12); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_13); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_14); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_15); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_16); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_17); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_18); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_19); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_20); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_21); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_22); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_23); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_24); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_25); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_26); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_27); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_28); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_29); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_30); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_31); - if (metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass) != null && !metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).isEmpty()) { - for (EClass subClass : metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass)) { - - stringBuffer.append(TEXT_32); - stringBuffer.append(metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).iterator().next() == subClass ? "" : "else "); - stringBuffer.append(TEXT_33); - stringBuffer.append(subClass.getName()); - stringBuffer.append(TEXT_34); - stringBuffer.append(subClass.getName()); - stringBuffer.append(TEXT_35); - - } - } - - stringBuffer.append(TEXT_36); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_37); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_38); - if (eClass.getEAnnotation("nodatabase") == null) { - stringBuffer.append(TEXT_39); - } - - for (EAttribute eAttribute : eClass.getEAllAttributes()) { - if (eAttribute.getEType() instanceof EEnum) { - - stringBuffer.append(TEXT_40); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_41); - stringBuffer.append(eAttribute.getEType().getName()); - stringBuffer.append(TEXT_42); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_43); - - } else { - if (eAttribute.isMany()) { - - stringBuffer.append(TEXT_44); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_45); - stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_46); - - } else { - - stringBuffer.append(TEXT_47); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_48); - stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_49); - - } - } - } - for (EReference eReference : eClass.getEAllReferences()) { - if (eReference.isMany()) { - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_50); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_51); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_52); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_53); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_54); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_55); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_56); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_57); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_58); - - } else { - - stringBuffer.append(TEXT_59); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_60); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_61); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_62); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_63); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_64); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_65); - - } - } else { - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_66); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_67); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_68); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_69); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_70); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_71); - - } else { - - stringBuffer.append(TEXT_72); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_73); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_74); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_75); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_76); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_77); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_78); - - } - } - } - - stringBuffer.append(TEXT_79); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_80); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_81); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_82); - stringBuffer.append(StringUtils.firstUpperCase(eClass.getEPackage().getName())); - stringBuffer.append(TEXT_83); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_84); - if (eClass.getEAnnotation("nodatabase") == null) { - stringBuffer.append(TEXT_85); - } - stringBuffer.append(TEXT_86); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_87); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_88); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_89); - - if (!metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).isEmpty()) { - for (EClass subClass : metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass)) { - - stringBuffer.append(TEXT_90); - stringBuffer.append(metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).iterator().next() == subClass ? "" : "else "); - stringBuffer.append(TEXT_91); - stringBuffer.append(subClass.getName()); - stringBuffer.append(TEXT_92); - stringBuffer.append(subClass.getName()); - stringBuffer.append(TEXT_93); - - } - } - for (EAttribute eAttribute : eClass.getEAllAttributes()) { - if (eAttribute.getEType() instanceof EEnum) { - - stringBuffer.append(TEXT_94); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_95); - stringBuffer.append(eAttribute.getEType().getName()); - stringBuffer.append(TEXT_96); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_97); - - } else { - if (eAttribute.isMany()) { - - stringBuffer.append(TEXT_98); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_99); - stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_100); - - } else { - - stringBuffer.append(TEXT_101); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_102); - stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); - stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); - stringBuffer.append(TEXT_103); - - } - } - } - for (EReference eReference : eClass.getEAllReferences()) { - if (eReference.isMany()) { - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_104); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_105); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_106); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_107); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_108); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_109); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_110); - - } else { - - stringBuffer.append(TEXT_111); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_112); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_113); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_114); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_115); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_116); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_117); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getEType().getEPackage().getName())); - stringBuffer.append(TEXT_118); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_119); - - } - } else { - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_120); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_121); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_122); - - } else { - - stringBuffer.append(TEXT_123); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_124); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_125); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getEType().getEPackage().getName())); - stringBuffer.append(TEXT_126); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_127); - stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); - stringBuffer.append(TEXT_128); - - } - } - } - - stringBuffer.append(TEXT_129); - - } else if (eClassifier instanceof EEnum) { - EEnum eEnum = (EEnum)eClassifier; - - stringBuffer.append(TEXT_130); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_131); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_132); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_133); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_134); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_135); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_136); - - } - } -} -} catch (Exception e) { - e.printStackTrace(); -} - - stringBuffer.append(TEXT_137); - return stringBuffer.toString(); - } -} +package org.bimserver.tools.generators; + +import org.eclipse.emf.ecore.*; +import org.bimserver.utils.*; +import org.bimserver.emf.MetaDataManager; +import java.io.File; +import java.util.Set; +import org.bimserver.utils.StringUtils; + +public class SConverterGenerator +{ + protected static String nl; + public static synchronized SConverterGenerator create(String lineSeparator) + { + nl = lineSeparator; + SConverterGenerator result = new SConverterGenerator(); + nl = null; + return result; + } + + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = "package org.bimserver.interfaces;"; + protected final String TEXT_2 = NL; + protected final String TEXT_3 = NL; + protected final String TEXT_4 = NL + NL + "import org.bimserver.emf.IdEObjectImpl;" + NL + "import org.bimserver.interfaces.objects.*;" + NL + "import java.util.*;" + NL + "import org.bimserver.models.log.*;" + NL + "import org.bimserver.models.store.*;" + NL + "import org.bimserver.database.DatabaseSession;" + NL + "import org.bimserver.database.BimserverDatabaseException;" + NL + "import org.bimserver.database.Query;" + NL + "" + NL + "public class SConverter {"; + protected final String TEXT_5 = NL + NL + "\tpublic Set list"; + protected final String TEXT_60 = " = new ArrayList();" + NL + "\t\tfor ("; + protected final String TEXT_61 = " v : input.get"; + protected final String TEXT_62 = "()) {" + NL + "\t\t\tlist"; + protected final String TEXT_63 = ".add(v.getOid());" + NL + "\t\t}" + NL + "\t\tresult.set"; + protected final String TEXT_64 = "(list"; + protected final String TEXT_65 = ");"; + protected final String TEXT_66 = NL + "\t\t"; + protected final String TEXT_67 = " "; + protected final String TEXT_68 = "Val = input.get"; + protected final String TEXT_69 = "();" + NL + "\t\tresult.set"; + protected final String TEXT_70 = "(convertToSObject("; + protected final String TEXT_71 = "Val));"; + protected final String TEXT_72 = NL + "\t\t"; + protected final String TEXT_73 = " "; + protected final String TEXT_74 = "Val = input.get"; + protected final String TEXT_75 = "();" + NL + "\t\tresult.set"; + protected final String TEXT_76 = "Id("; + protected final String TEXT_77 = "Val == null ? -1 : "; + protected final String TEXT_78 = "Val.getOid());"; + protected final String TEXT_79 = NL + "\t\treturn result;" + NL + "\t}" + NL + "\tpublic "; + protected final String TEXT_80 = " convertFromSObject(S"; + protected final String TEXT_81 = " input, DatabaseSession session) throws BimserverDatabaseException {" + NL + "\t\t"; + protected final String TEXT_82 = " result = convertFromSObject(input, "; + protected final String TEXT_83 = "Factory.eINSTANCE.create"; + protected final String TEXT_84 = "(), session);" + NL + "\t\t"; + protected final String TEXT_85 = NL + "\t\t((IdEObjectImpl)result).setOid(input.getOid());" + NL + "\t\t((IdEObjectImpl)result).setRid(input.getRid());" + NL + "\t\t"; + protected final String TEXT_86 = NL + "\t\treturn result;" + NL + "\t}" + NL + "" + NL + "\tpublic "; + protected final String TEXT_87 = " convertFromSObject(S"; + protected final String TEXT_88 = " input, "; + protected final String TEXT_89 = " result, DatabaseSession session) throws BimserverDatabaseException {" + NL + "\t\tif (input == null) {" + NL + "\t\t\treturn null;" + NL + "\t\t}"; + protected final String TEXT_90 = NL + "\t\t"; + protected final String TEXT_91 = "if (input instanceof S"; + protected final String TEXT_92 = ") {" + NL + "\t\t\treturn convertFromSObject((S"; + protected final String TEXT_93 = ")input, session);" + NL + "\t\t}"; + protected final String TEXT_94 = NL + "\t\tresult.set"; + protected final String TEXT_95 = "("; + protected final String TEXT_96 = ".values()[input.get"; + protected final String TEXT_97 = "().ordinal()]);"; + protected final String TEXT_98 = NL + "\t\tresult.get"; + protected final String TEXT_99 = "().addAll(input."; + protected final String TEXT_100 = "());"; + protected final String TEXT_101 = NL + "\t\tresult.set"; + protected final String TEXT_102 = "(input."; + protected final String TEXT_103 = "());"; + protected final String TEXT_104 = NL + "\t\tList<"; + protected final String TEXT_105 = "> list"; + protected final String TEXT_106 = " = result.get"; + protected final String TEXT_107 = "();" + NL + "\t\tfor (S"; + protected final String TEXT_108 = " v : input.get"; + protected final String TEXT_109 = "()) {" + NL + "\t\t\tlist"; + protected final String TEXT_110 = ".add(convertFromSObject(v, session));" + NL + "\t\t}"; + protected final String TEXT_111 = NL + "\t\tList<"; + protected final String TEXT_112 = "> list"; + protected final String TEXT_113 = " = result.get"; + protected final String TEXT_114 = "();" + NL + "\t\tfor (long oid : input.get"; + protected final String TEXT_115 = "()) {" + NL + "\t\t\tlist"; + protected final String TEXT_116 = ".add(("; + protected final String TEXT_117 = ")session.get("; + protected final String TEXT_118 = "Package.eINSTANCE.get"; + protected final String TEXT_119 = "(), oid, Query.getDefault()));" + NL + "\t\t}"; + protected final String TEXT_120 = NL + "\t\tresult.set"; + protected final String TEXT_121 = "(convertFromSObject(input.get"; + protected final String TEXT_122 = "(), session));"; + protected final String TEXT_123 = NL + "\t\tresult.set"; + protected final String TEXT_124 = "(("; + protected final String TEXT_125 = ")session.get("; + protected final String TEXT_126 = "Package.eINSTANCE.get"; + protected final String TEXT_127 = "(), input.get"; + protected final String TEXT_128 = "Id(), Query.getDefault()));"; + protected final String TEXT_129 = NL + "\t\treturn result;" + NL + "\t}"; + protected final String TEXT_130 = NL + "\t\tpublic S"; + protected final String TEXT_131 = " convertToSObject("; + protected final String TEXT_132 = " input) {" + NL + "\t\t\treturn S"; + protected final String TEXT_133 = ".values()[input.ordinal()];" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\tpublic "; + protected final String TEXT_134 = " convertFromSObject(S"; + protected final String TEXT_135 = " input) {" + NL + "\t\t\treturn "; + protected final String TEXT_136 = ".values()[input.ordinal()];" + NL + "\t\t}"; + protected final String TEXT_137 = NL + "}"; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(TEXT_1); + +/****************************************************************************** + * Copyright (C) 2009-2012 BIMserver.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + *****************************************************************************/ + + stringBuffer.append(TEXT_2); + stringBuffer.append(TEXT_3); + stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); + stringBuffer.append(TEXT_4); + + try { + Object[] argumentsArray = (Object[])argument; + MetaDataManager metaDataManager = (MetaDataManager)argumentsArray[0]; + @SuppressWarnings("unchecked") Set ePackages = (Set)argumentsArray[1]; + for (EPackage ePackage : ePackages) { + for (EClassifier eClassifier : ePackage.getEClassifiers()) { + if (eClassifier instanceof EClass) { + EClass eClass = (EClass)eClassifier; + + stringBuffer.append(TEXT_5); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_6); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_7); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_8); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_9); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_10); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_11); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_12); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_13); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_14); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_15); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_16); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_17); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_18); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_19); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_20); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_21); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_22); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_23); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_24); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_25); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_26); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_27); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_28); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_29); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_30); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_31); + if (metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass) != null && !metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).isEmpty()) { + for (EClass subClass : metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass)) { + + stringBuffer.append(TEXT_32); + stringBuffer.append(metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).iterator().next() == subClass ? "" : "else "); + stringBuffer.append(TEXT_33); + stringBuffer.append(subClass.getName()); + stringBuffer.append(TEXT_34); + stringBuffer.append(subClass.getName()); + stringBuffer.append(TEXT_35); + + } + } + + stringBuffer.append(TEXT_36); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_37); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_38); + if (eClass.getEAnnotation("nodatabase") == null) { + stringBuffer.append(TEXT_39); + } + + for (EAttribute eAttribute : eClass.getEAllAttributes()) { + if (eAttribute.getEType() instanceof EEnum) { + + stringBuffer.append(TEXT_40); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_41); + stringBuffer.append(eAttribute.getEType().getName()); + stringBuffer.append(TEXT_42); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_43); + + } else { + if (eAttribute.isMany()) { + + stringBuffer.append(TEXT_44); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_45); + stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_46); + + } else { + + stringBuffer.append(TEXT_47); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_48); + stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_49); + + } + } + } + for (EReference eReference : eClass.getEAllReferences()) { + if (eReference.isMany()) { + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_50); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_51); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_52); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_53); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_54); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_55); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_56); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_57); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_58); + + } else { + + stringBuffer.append(TEXT_59); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_60); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_61); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_62); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_63); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_64); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_65); + + } + } else { + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_66); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_67); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_68); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_69); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_70); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_71); + + } else { + + stringBuffer.append(TEXT_72); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_73); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_74); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_75); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_76); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_77); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_78); + + } + } + } + + stringBuffer.append(TEXT_79); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_80); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_81); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_82); + stringBuffer.append(StringUtils.firstUpperCase(eClass.getEPackage().getName())); + stringBuffer.append(TEXT_83); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_84); + if (eClass.getEAnnotation("nodatabase") == null) { + stringBuffer.append(TEXT_85); + } + stringBuffer.append(TEXT_86); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_87); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_88); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_89); + + if (!metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).isEmpty()) { + for (EClass subClass : metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass)) { + + stringBuffer.append(TEXT_90); + stringBuffer.append(metaDataManager.getPackageMetaData(ePackage.getName()).getDirectSubClasses(eClass).iterator().next() == subClass ? "" : "else "); + stringBuffer.append(TEXT_91); + stringBuffer.append(subClass.getName()); + stringBuffer.append(TEXT_92); + stringBuffer.append(subClass.getName()); + stringBuffer.append(TEXT_93); + + } + } + for (EAttribute eAttribute : eClass.getEAllAttributes()) { + if (eAttribute.getEType() instanceof EEnum) { + + stringBuffer.append(TEXT_94); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_95); + stringBuffer.append(eAttribute.getEType().getName()); + stringBuffer.append(TEXT_96); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_97); + + } else { + if (eAttribute.isMany()) { + + stringBuffer.append(TEXT_98); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_99); + stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_100); + + } else { + + stringBuffer.append(TEXT_101); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_102); + stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); + stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); + stringBuffer.append(TEXT_103); + + } + } + } + for (EReference eReference : eClass.getEAllReferences()) { + if (eReference.isMany()) { + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_104); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_105); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_106); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_107); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_108); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_109); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_110); + + } else { + + stringBuffer.append(TEXT_111); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_112); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_113); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_114); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_115); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_116); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_117); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getEType().getEPackage().getName())); + stringBuffer.append(TEXT_118); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_119); + + } + } else { + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_120); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_121); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_122); + + } else { + + stringBuffer.append(TEXT_123); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_124); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_125); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getEType().getEPackage().getName())); + stringBuffer.append(TEXT_126); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_127); + stringBuffer.append(StringUtils.firstUpperCase(eReference.getName())); + stringBuffer.append(TEXT_128); + + } + } + } + + stringBuffer.append(TEXT_129); + + } else if (eClassifier instanceof EEnum) { + EEnum eEnum = (EEnum)eClassifier; + + stringBuffer.append(TEXT_130); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_131); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_132); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_133); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_134); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_135); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_136); + + } + } +} +} catch (Exception e) { + e.printStackTrace(); +} + + stringBuffer.append(TEXT_137); + return stringBuffer.toString(); + } +} diff --git a/BimServer/generated/org/bimserver/tools/generators/SPackageGenerator.java b/BimServer/generated/org/bimserver/tools/generators/SPackageGenerator.java index 1b7b2a3520..82ca3f20d3 100644 --- a/BimServer/generated/org/bimserver/tools/generators/SPackageGenerator.java +++ b/BimServer/generated/org/bimserver/tools/generators/SPackageGenerator.java @@ -1,75 +1,75 @@ -package org.bimserver.tools.generators; - -import org.eclipse.emf.ecore.*; -import org.bimserver.utils.*; -import java.io.File; -import java.util.Set; - -public class SPackageGenerator -{ - protected static String nl; - public static synchronized SPackageGenerator create(String lineSeparator) - { - nl = lineSeparator; - SPackageGenerator result = new SPackageGenerator(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package org.bimserver.shared.meta;"; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = NL + NL + "import java.util.*;" + NL + "import org.bimserver.shared.meta.SClass;" + NL + "import org.slf4j.Logger;" + NL + "import org.slf4j.LoggerFactory;" + NL + "" + NL + "public class SPackage {" + NL + "\tprivate static final Logger LOGGER = LoggerFactory.getLogger(SPackage.class);"; - protected final String TEXT_5 = NL + NL + "\tprivate static final SPackage sPackage = new SPackage();" + NL + "\tprivate final Map sClasses = new HashMap();" + NL + "" + NL + "\tstatic {" + NL + "\t\tgetInstance().init();" + NL + "\t}" + NL + "" + NL + "\tprivate void init() {" + NL + "\t\t\ttry {" + NL + "\t"; - protected final String TEXT_6 = NL + "\t\tClass.forName(\"org.bimserver.interfaces.objects.S"; - protected final String TEXT_7 = "\");"; - protected final String TEXT_8 = NL + "\t\t} catch (ClassNotFoundException e) {" + NL + "\t\t\tLOGGER.error(\"\", e);" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\tpublic static SPackage getInstance() {" + NL + "\t\treturn sPackage;" + NL + "\t}" + NL + "" + NL + "\tpublic void addSClass(SClass sClass) {" + NL + "\t\tsClasses.put(sClass.getName(), sClass);" + NL + "\t}" + NL + "" + NL + "\tpublic SClass getSClass(String name) {" + NL + "\t\treturn sClasses.get(name);" + NL + "\t}" + NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(TEXT_1); - -/****************************************************************************** - * Copyright (C) 2009-2012 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); - stringBuffer.append(TEXT_4); - - @SuppressWarnings("unchecked") Set ePackages = (Set)argument; - - stringBuffer.append(TEXT_5); - - for (EPackage ePackage : ePackages) { - for (EClassifier eClassifier : ePackage.getEClassifiers()) { - if (eClassifier instanceof EClass || eClassifier instanceof EEnum) { - - stringBuffer.append(TEXT_6); - stringBuffer.append(eClassifier.getName()); - stringBuffer.append(TEXT_7); - - } - } - } - - stringBuffer.append(TEXT_8); - return stringBuffer.toString(); - } -} +package org.bimserver.tools.generators; + +import org.eclipse.emf.ecore.*; +import org.bimserver.utils.*; +import java.io.File; +import java.util.Set; + +public class SPackageGenerator +{ + protected static String nl; + public static synchronized SPackageGenerator create(String lineSeparator) + { + nl = lineSeparator; + SPackageGenerator result = new SPackageGenerator(); + nl = null; + return result; + } + + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = "package org.bimserver.shared.meta;"; + protected final String TEXT_2 = NL; + protected final String TEXT_3 = NL; + protected final String TEXT_4 = NL + NL + "import java.util.*;" + NL + "import org.bimserver.shared.meta.SClass;" + NL + "import org.slf4j.Logger;" + NL + "import org.slf4j.LoggerFactory;" + NL + "" + NL + "public class SPackage {" + NL + "\tprivate static final Logger LOGGER = LoggerFactory.getLogger(SPackage.class);"; + protected final String TEXT_5 = NL + NL + "\tprivate static final SPackage sPackage = new SPackage();" + NL + "\tprivate final Map sClasses = new HashMap();" + NL + "" + NL + "\tstatic {" + NL + "\t\tgetInstance().init();" + NL + "\t}" + NL + "" + NL + "\tprivate void init() {" + NL + "\t\t\ttry {" + NL + "\t"; + protected final String TEXT_6 = NL + "\t\tClass.forName(\"org.bimserver.interfaces.objects.S"; + protected final String TEXT_7 = "\");"; + protected final String TEXT_8 = NL + "\t\t} catch (ClassNotFoundException e) {" + NL + "\t\t\tLOGGER.error(\"\", e);" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\tpublic static SPackage getInstance() {" + NL + "\t\treturn sPackage;" + NL + "\t}" + NL + "" + NL + "\tpublic void addSClass(SClass sClass) {" + NL + "\t\tsClasses.put(sClass.getName(), sClass);" + NL + "\t}" + NL + "" + NL + "\tpublic SClass getSClass(String name) {" + NL + "\t\treturn sClasses.get(name);" + NL + "\t}" + NL + "}"; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(TEXT_1); + +/****************************************************************************** + * Copyright (C) 2009-2012 BIMserver.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + *****************************************************************************/ + + stringBuffer.append(TEXT_2); + stringBuffer.append(TEXT_3); + stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); + stringBuffer.append(TEXT_4); + + @SuppressWarnings("unchecked") Set ePackages = (Set)argument; + + stringBuffer.append(TEXT_5); + + for (EPackage ePackage : ePackages) { + for (EClassifier eClassifier : ePackage.getEClassifiers()) { + if (eClassifier instanceof EClass || eClassifier instanceof EEnum) { + + stringBuffer.append(TEXT_6); + stringBuffer.append(eClassifier.getName()); + stringBuffer.append(TEXT_7); + + } + } + } + + stringBuffer.append(TEXT_8); + return stringBuffer.toString(); + } +} diff --git a/BimServer/generated/org/bimserver/tools/generators/SServiceGenerator.java b/BimServer/generated/org/bimserver/tools/generators/SServiceGenerator.java index f9b35b0860..2ae33da7bd 100644 --- a/BimServer/generated/org/bimserver/tools/generators/SServiceGenerator.java +++ b/BimServer/generated/org/bimserver/tools/generators/SServiceGenerator.java @@ -1,94 +1,94 @@ -package org.bimserver.tools.generators; - -import org.eclipse.emf.ecore.*; -import org.bimserver.utils.*; -import java.io.File; - -public class SServiceGenerator -{ - protected static String nl; - public static synchronized SServiceGenerator create(String lineSeparator) - { - nl = lineSeparator; - SServiceGenerator result = new SServiceGenerator(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package org.bimserver.interfaces;" + NL; - protected final String TEXT_2 = NL + NL + "import org.bimserver.shared.meta.*;" + NL + "import org.slf4j.Logger;" + NL + "import org.slf4j.LoggerFactory;" + NL + "import org.bimserver.shared.interfaces.PublicInterface;" + NL; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = NL; - protected final String TEXT_5 = NL + NL + "public class S"; - protected final String TEXT_6 = "Service extends org.bimserver.shared.meta.SService {" + NL + "\tprivate static final Logger LOGGER = LoggerFactory.getLogger(S"; - protected final String TEXT_7 = "Service.class);" + NL + "" + NL + "\tpublic S"; - protected final String TEXT_8 = "Service(SServicesMap servicesMap, SourceCodeFetcher sourceCodeFetcher, Class cl) {" + NL + "\t\tsuper(servicesMap, sourceCodeFetcher, cl);" + NL + "\t}" + NL + "\t" + NL + "\t\tpublic void init() {" + NL + "\t\t\ttry {"; - protected final String TEXT_9 = NL + "\t\t\t\tgetServicesMap().addType(new SClass(getServicesMap(), Class.forName(\"org.bimserver.interfaces.objects.S"; - protected final String TEXT_10 = "\"), new SConstructor(){" + NL + "\t\t\t\t\tpublic Object newInstance() {" + NL + "\t\t\t\t\t\treturn new org.bimserver.interfaces.objects.S"; - protected final String TEXT_11 = "();" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}));"; - protected final String TEXT_12 = NL + "\t\t\t\tgetServicesMap().addType(new SClass(getServicesMap(), Class.forName(\"org.bimserver.interfaces.objects.S"; - protected final String TEXT_13 = "\"), null));"; - protected final String TEXT_14 = NL + "\t\t\tsuper.init();" + NL + "\t\t} catch (ClassNotFoundException e) {" + NL + "\t\t\tLOGGER.error(\"\", e);" + NL + "\t\t}" + NL + "\t}" + NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(TEXT_1); - -/****************************************************************************** - * Copyright (C) 2009-2012 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); - stringBuffer.append(TEXT_4); - -Object[] args = (Object[])argument; -Class cl = (Class)args[0]; -EPackage ePackage = (EPackage)args[1]; - - stringBuffer.append(TEXT_5); - stringBuffer.append(cl.getSimpleName()); - stringBuffer.append(TEXT_6); - stringBuffer.append(cl.getSimpleName()); - stringBuffer.append(TEXT_7); - stringBuffer.append(cl.getSimpleName()); - stringBuffer.append(TEXT_8); - - for (EClassifier eClassifier : ePackage.getEClassifiers()) { - if (eClassifier instanceof EClass) { - - stringBuffer.append(TEXT_9); - stringBuffer.append(eClassifier.getName()); - stringBuffer.append(TEXT_10); - stringBuffer.append(eClassifier.getName()); - stringBuffer.append(TEXT_11); - - } else if (eClassifier instanceof EEnum) { - - stringBuffer.append(TEXT_12); - stringBuffer.append(eClassifier.getName()); - stringBuffer.append(TEXT_13); - - } - } - - stringBuffer.append(TEXT_14); - return stringBuffer.toString(); - } -} +package org.bimserver.tools.generators; + +import org.eclipse.emf.ecore.*; +import org.bimserver.utils.*; +import java.io.File; + +public class SServiceGenerator +{ + protected static String nl; + public static synchronized SServiceGenerator create(String lineSeparator) + { + nl = lineSeparator; + SServiceGenerator result = new SServiceGenerator(); + nl = null; + return result; + } + + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = "package org.bimserver.interfaces;" + NL; + protected final String TEXT_2 = NL + NL + "import org.bimserver.shared.meta.*;" + NL + "import org.slf4j.Logger;" + NL + "import org.slf4j.LoggerFactory;" + NL + "import org.bimserver.shared.interfaces.PublicInterface;" + NL; + protected final String TEXT_3 = NL; + protected final String TEXT_4 = NL; + protected final String TEXT_5 = NL + NL + "public class S"; + protected final String TEXT_6 = "Service extends org.bimserver.shared.meta.SService {" + NL + "\tprivate static final Logger LOGGER = LoggerFactory.getLogger(S"; + protected final String TEXT_7 = "Service.class);" + NL + "" + NL + "\tpublic S"; + protected final String TEXT_8 = "Service(SServicesMap servicesMap, SourceCodeFetcher sourceCodeFetcher, Class cl) {" + NL + "\t\tsuper(servicesMap, sourceCodeFetcher, cl);" + NL + "\t}" + NL + "\t" + NL + "\t\tpublic void init() {" + NL + "\t\t\ttry {"; + protected final String TEXT_9 = NL + "\t\t\t\tgetServicesMap().addType(new SClass(getServicesMap(), Class.forName(\"org.bimserver.interfaces.objects.S"; + protected final String TEXT_10 = "\"), new SConstructor(){" + NL + "\t\t\t\t\tpublic Object newInstance() {" + NL + "\t\t\t\t\t\treturn new org.bimserver.interfaces.objects.S"; + protected final String TEXT_11 = "();" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}));"; + protected final String TEXT_12 = NL + "\t\t\t\tgetServicesMap().addType(new SClass(getServicesMap(), Class.forName(\"org.bimserver.interfaces.objects.S"; + protected final String TEXT_13 = "\"), null));"; + protected final String TEXT_14 = NL + "\t\t\tsuper.init();" + NL + "\t\t} catch (ClassNotFoundException e) {" + NL + "\t\t\tLOGGER.error(\"\", e);" + NL + "\t\t}" + NL + "\t}" + NL + "}"; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(TEXT_1); + +/****************************************************************************** + * Copyright (C) 2009-2012 BIMserver.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + *****************************************************************************/ + + stringBuffer.append(TEXT_2); + stringBuffer.append(TEXT_3); + stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); + stringBuffer.append(TEXT_4); + +Object[] args = (Object[])argument; +Class cl = (Class)args[0]; +EPackage ePackage = (EPackage)args[1]; + + stringBuffer.append(TEXT_5); + stringBuffer.append(cl.getSimpleName()); + stringBuffer.append(TEXT_6); + stringBuffer.append(cl.getSimpleName()); + stringBuffer.append(TEXT_7); + stringBuffer.append(cl.getSimpleName()); + stringBuffer.append(TEXT_8); + + for (EClassifier eClassifier : ePackage.getEClassifiers()) { + if (eClassifier instanceof EClass) { + + stringBuffer.append(TEXT_9); + stringBuffer.append(eClassifier.getName()); + stringBuffer.append(TEXT_10); + stringBuffer.append(eClassifier.getName()); + stringBuffer.append(TEXT_11); + + } else if (eClassifier instanceof EEnum) { + + stringBuffer.append(TEXT_12); + stringBuffer.append(eClassifier.getName()); + stringBuffer.append(TEXT_13); + + } + } + + stringBuffer.append(TEXT_14); + return stringBuffer.toString(); + } +} diff --git a/BimServer/generated/org/bimserver/tools/generators/ServiceInterfaceObjectGenerator.java b/BimServer/generated/org/bimserver/tools/generators/ServiceInterfaceObjectGenerator.java index c5bcc2ecb8..1cce2aeedf 100644 --- a/BimServer/generated/org/bimserver/tools/generators/ServiceInterfaceObjectGenerator.java +++ b/BimServer/generated/org/bimserver/tools/generators/ServiceInterfaceObjectGenerator.java @@ -1,599 +1,599 @@ -package org.bimserver.tools.generators; - -import org.eclipse.emf.ecore.*; -import org.bimserver.utils.*; -import org.bimserver.emf.MetaDataManager; -import java.io.File; -import org.bimserver.utils.StringUtils; - -public class ServiceInterfaceObjectGenerator -{ - protected static String nl; - public static synchronized ServiceInterfaceObjectGenerator create(String lineSeparator) - { - nl = lineSeparator; - ServiceInterfaceObjectGenerator result = new ServiceInterfaceObjectGenerator(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package org.bimserver.interfaces.objects;"; - protected final String TEXT_2 = NL; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = NL; - protected final String TEXT_5 = NL + NL + "@XmlRootElement"; - protected final String TEXT_6 = NL + "@XmlSeeAlso(value={"; - protected final String TEXT_7 = "S"; - protected final String TEXT_8 = ".class"; - protected final String TEXT_9 = ", "; - protected final String TEXT_10 = "})"; - protected final String TEXT_11 = NL + "public class S"; - protected final String TEXT_12 = " extends "; - protected final String TEXT_13 = "S"; - protected final String TEXT_14 = " implements "; - protected final String TEXT_15 = NL + "{"; - protected final String TEXT_16 = NL + "\tprivate long oid = -1;" + NL + "\tprivate int rid = 0;"; - protected final String TEXT_17 = NL + NL + "\t@XmlTransient" + NL + "\tprivate static SClass sClass;"; - protected final String TEXT_18 = NL + "\tprivate S"; - protected final String TEXT_19 = " "; - protected final String TEXT_20 = ";"; - protected final String TEXT_21 = NL + "\tprivate List<"; - protected final String TEXT_22 = "> "; - protected final String TEXT_23 = " = new ArrayList<"; - protected final String TEXT_24 = ">();"; - protected final String TEXT_25 = NL + "\t@XmlMimeType(\"application/octet-stream\")" + NL + "\tprivate DataHandler "; - protected final String TEXT_26 = ";"; - protected final String TEXT_27 = NL + "\tprivate "; - protected final String TEXT_28 = " "; - protected final String TEXT_29 = ";"; - protected final String TEXT_30 = NL + "\tprivate List "; - protected final String TEXT_35 = " = new ArrayList();"; - protected final String TEXT_36 = NL + "\tprivate S"; - protected final String TEXT_37 = " "; - protected final String TEXT_38 = ";"; - protected final String TEXT_39 = NL + "\tprivate long "; - protected final String TEXT_40 = "Id = -1;"; - protected final String TEXT_41 = NL + NL + "\tpublic long getOid() {" + NL + "\t\treturn this.oid;" + NL + "\t}" + NL + "" + NL + "\tpublic void setOid(long oid) {" + NL + "\t\tthis.oid = oid;" + NL + "\t}" + NL + "" + NL + "\tpublic int getRid() {" + NL + "\t\treturn rid;" + NL + "\t}" + NL + "\t" + NL + "\tpublic void setRid(int rid) {" + NL + "\t\tthis.rid = rid;" + NL + "\t}"; - protected final String TEXT_42 = NL + "\t" + NL + "\t@XmlTransient" + NL + "\tpublic SClass getSClass() {" + NL + "\t\treturn sClass;" + NL + "\t}" + NL + "\t" + NL + "\tpublic static void setSClass(SClass sClass) {" + NL + "\t\tS"; - protected final String TEXT_43 = ".sClass = sClass;" + NL + "\t}" + NL + "" + NL + "\tpublic Object sGet(SField sField) {"; - protected final String TEXT_44 = NL + "\t\tif (sField.getName().equals(\""; - protected final String TEXT_45 = "\")) {" + NL + "\t\t\treturn "; - protected final String TEXT_46 = "();" + NL + "\t\t}"; - protected final String TEXT_47 = NL + "\t\tif (sField.getName().equals(\"oid\")) {" + NL + "\t\t\treturn getOid();" + NL + "\t\t}" + NL + "\t\tif (sField.getName().equals(\"rid\")) {" + NL + "\t\t\treturn getRid();" + NL + "\t\t}"; - protected final String TEXT_48 = NL + "\t\tthrow new RuntimeException(\"Field \" + sField.getName() + \" not found\");" + NL + "\t}"; - protected final String TEXT_49 = NL + "\t@SuppressWarnings(\"unchecked\")"; - protected final String TEXT_50 = NL + NL + "\tpublic void sSet(SField sField, Object val) {"; - protected final String TEXT_51 = NL + "\t\tif (sField.getName().equals(\""; - protected final String TEXT_52 = "\")) {" + NL + "\t\t\tset"; - protected final String TEXT_53 = "(("; - protected final String TEXT_54 = ")val);" + NL + "\t\t\treturn;" + NL + "\t\t}"; - protected final String TEXT_55 = NL + "\t\tif (sField.getName().equals(\"oid\")) {" + NL + "\t\t\tsetOid((Long)val);" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tif (sField.getName().equals(\"rid\")) {" + NL + "\t\t\tsetRid((Integer)val);" + NL + "\t\t\treturn;" + NL + "\t\t}"; - protected final String TEXT_56 = NL + "\t\tthrow new RuntimeException(\"Field \" + sField.getName() + \" not found\");" + NL + "\t}" + NL + "\t"; - protected final String TEXT_57 = NL + "\tpublic S"; - protected final String TEXT_58 = " "; - protected final String TEXT_59 = "() {" + NL + "\t\treturn "; - protected final String TEXT_60 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; - protected final String TEXT_61 = "(S"; - protected final String TEXT_62 = " "; - protected final String TEXT_63 = ") {" + NL + "\t\tthis."; - protected final String TEXT_64 = " = "; - protected final String TEXT_65 = ";" + NL + "\t}" + NL + "\t"; - protected final String TEXT_66 = NL + NL + "\tpublic List<"; - protected final String TEXT_67 = "> "; - protected final String TEXT_68 = "() {" + NL + "\t\treturn "; - protected final String TEXT_69 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; - protected final String TEXT_70 = "(List<"; - protected final String TEXT_71 = "> "; - protected final String TEXT_72 = ") {" + NL + "\t\tthis."; - protected final String TEXT_73 = " = "; - protected final String TEXT_74 = ";" + NL + "\t}" + NL + "\t"; - protected final String TEXT_75 = NL + "\tpublic DataHandler "; - protected final String TEXT_76 = "() {" + NL + "\t\treturn "; - protected final String TEXT_77 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; - protected final String TEXT_78 = "(DataHandler "; - protected final String TEXT_79 = ") {" + NL + "\t\tthis."; - protected final String TEXT_80 = " = "; - protected final String TEXT_81 = ";" + NL + "\t}" + NL + "\t"; - protected final String TEXT_82 = NL + "\tpublic "; - protected final String TEXT_83 = " "; - protected final String TEXT_84 = "() {" + NL + "\t\treturn "; - protected final String TEXT_85 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; - protected final String TEXT_86 = "("; - protected final String TEXT_87 = " "; - protected final String TEXT_88 = ") {" + NL + "\t\tthis."; - protected final String TEXT_89 = " = "; - protected final String TEXT_90 = ";" + NL + "\t}" + NL + "\t"; - protected final String TEXT_91 = NL + "\tpublic List "; - protected final String TEXT_101 = "() {" + NL + "\t\treturn "; - protected final String TEXT_102 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; - protected final String TEXT_103 = "(List "; - protected final String TEXT_104 = ") {" + NL + "\t\tthis."; - protected final String TEXT_105 = " = "; - protected final String TEXT_106 = ";" + NL + "\t}" + NL + "\t"; - protected final String TEXT_107 = NL + "\tpublic S"; - protected final String TEXT_108 = " "; - protected final String TEXT_109 = "() {" + NL + "\t\treturn "; - protected final String TEXT_110 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; - protected final String TEXT_111 = "(S"; - protected final String TEXT_112 = " "; - protected final String TEXT_113 = ") {" + NL + "\t\tthis."; - protected final String TEXT_114 = " = "; - protected final String TEXT_115 = ";" + NL + "\t}" + NL + "\t" + NL + "\t"; - protected final String TEXT_116 = NL + "\tpublic long "; - protected final String TEXT_117 = "() {" + NL + "\t\treturn "; - protected final String TEXT_118 = "Id;" + NL + "\t}" + NL + "" + NL + "\tpublic void "; - protected final String TEXT_119 = "(long "; - protected final String TEXT_120 = "Id) {" + NL + "\t\tthis."; - protected final String TEXT_121 = "Id = "; - protected final String TEXT_122 = "Id;" + NL + "\t}" + NL + "\t"; - protected final String TEXT_123 = NL + "\t@Override" + NL + "\tpublic int hashCode() {" + NL + "\t\tfinal int prime = 31;" + NL + "\t\tint result = 1;" + NL + "\t\tresult = prime * result + (int) (oid ^ (oid >>> 32));" + NL + "\t\treturn result;" + NL + "\t}" + NL + "" + NL + "\t@Override" + NL + "\tpublic boolean equals(Object obj) {" + NL + "\t\tif (this == obj)" + NL + "\t\t\treturn true;" + NL + "\t\tif (obj == null)" + NL + "\t\t\treturn false;" + NL + "\t\tif (getClass() != obj.getClass())" + NL + "\t\t\treturn false;" + NL + "\t\tS"; - protected final String TEXT_124 = " other = (S"; - protected final String TEXT_125 = ") obj;" + NL + "\t\tif (oid != other.oid)" + NL + "\t\t\treturn false;" + NL + "\t\treturn true;" + NL + "\t}"; - protected final String TEXT_126 = NL + "public enum S"; - protected final String TEXT_127 = " {"; - protected final String TEXT_128 = NL + "\t"; - protected final String TEXT_129 = "("; - protected final String TEXT_130 = ")"; - protected final String TEXT_131 = NL + "\tint ordinal;" + NL + "" + NL + "\tS"; - protected final String TEXT_132 = "(int ordinal) {" + NL + "\t\tthis.ordinal = ordinal;" + NL + "\t}" + NL + "\t" + NL + "\tpublic int getOrdinal() {" + NL + "\t\treturn ordinal;" + NL + "\t}"; - protected final String TEXT_133 = NL + "}"; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(TEXT_1); - -/****************************************************************************** - * Copyright (C) 2009-2012 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - - stringBuffer.append(TEXT_2); - stringBuffer.append(TEXT_3); - stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); - stringBuffer.append(TEXT_4); - - Object[] arguments = (Object[])argument; - EClassifier eClassifier = (EClassifier)arguments[0]; - ImportManager importManager = (ImportManager)arguments[1]; - MetaDataManager metaDataManager = (MetaDataManager)arguments[2]; - importManager.mark(stringBuffer); - boolean hasLists = false; - if (eClassifier instanceof EClass) { - EClass eClass = (EClass)eClassifier; - for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { - if (eStructuralFeature.isMany()) { - hasLists = true; - break; - } - } - - importManager.getImport("javax.xml.bind.annotation.XmlRootElement"); - importManager.getImport("org.bimserver.shared.meta.*"); - - stringBuffer.append(TEXT_5); - -importManager.getImport("javax.xml.bind.annotation.XmlTransient"); -if (metaDataManager.getPackageMetaData(eClassifier.getEPackage().getName()).getDirectSubClasses(eClass) != null && !metaDataManager.getPackageMetaData(eClassifier.getEPackage().getName()).getDirectSubClasses(eClass).isEmpty()) { -importManager.getImport("javax.xml.bind.annotation.XmlSeeAlso"); - - stringBuffer.append(TEXT_6); - -java.util.Set subClasses = metaDataManager.getPackageMetaData(eClassifier.getEPackage().getName()).getDirectSubClasses(eClass); -int i=0; -for (EClass subClass : subClasses) { - - stringBuffer.append(TEXT_7); - stringBuffer.append(subClass.getName()); - stringBuffer.append(TEXT_8); - - if (i != subClasses.size() - 1) { - - stringBuffer.append(TEXT_9); - - } - i++; -} - stringBuffer.append(TEXT_10); - -} - - stringBuffer.append(TEXT_11); - stringBuffer.append(eClass.getName()); - - if (!eClass.getESuperTypes().isEmpty()) { - - stringBuffer.append(TEXT_12); - - for (EClass eSuperClass : eClass.getESuperTypes()) { - - stringBuffer.append(TEXT_13); - stringBuffer.append(eSuperClass.getName()); - - } - } - - stringBuffer.append(TEXT_14); - stringBuffer.append( eClass.getEAnnotation("nodatabase") != null ? "SBase" : "SDataBase" ); - stringBuffer.append(TEXT_15); - if (eClass.getEAnnotation("nodatabase") == null) { - stringBuffer.append(TEXT_16); - } - stringBuffer.append(TEXT_17); - - for (EStructuralFeature eStructuralFeature : eClass.getEStructuralFeatures()) { - if (eStructuralFeature.getEAnnotation("notinserviceinterface") == null) { - if (eStructuralFeature instanceof EAttribute) { - EAttribute eAttribute = (EAttribute)eStructuralFeature; - if (eAttribute.getEType() instanceof EEnum) { - - stringBuffer.append(TEXT_18); - stringBuffer.append(eAttribute.getEType().getName()); - stringBuffer.append(TEXT_19); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_20); - - } else { - if (eAttribute.isMany()) { - importManager.getImport("java.util.List"); - importManager.getImport("java.util.ArrayList"); - - stringBuffer.append(TEXT_21); - stringBuffer.append(eAttribute.getEType().getInstanceClassName()); - stringBuffer.append(TEXT_22); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_23); - stringBuffer.append(eAttribute.getEType().getInstanceClassName()); - stringBuffer.append(TEXT_24); - - } else { - if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray() && eAttribute.getEAnnotation("file") != null) { - importManager.getImport("javax.activation.DataHandler"); - - stringBuffer.append(TEXT_25); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_26); - - } else { - - stringBuffer.append(TEXT_27); - stringBuffer.append(eAttribute.getEType().getInstanceClassName()); - stringBuffer.append(TEXT_28); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_29); - - } - } - } - } else if (eStructuralFeature instanceof EReference) { - EReference eReference = (EReference)eStructuralFeature; - if (eReference.isMany()) { - importManager.getImport("java.util.List"); - importManager.getImport("java.util.ArrayList"); - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_30); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_31); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_32); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_33); - - } else { - - stringBuffer.append(TEXT_34); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_35); - - } - } else { - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_36); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_37); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_38); - - } else { - - stringBuffer.append(TEXT_39); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_40); - - } - } - } - } - } - - if (eClass.getEAnnotation("nodatabase") == null) { - stringBuffer.append(TEXT_41); - } - stringBuffer.append(TEXT_42); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_43); - - for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { - - stringBuffer.append(TEXT_44); - stringBuffer.append(eStructuralFeature.getName()); - stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); - stringBuffer.append(TEXT_45); - stringBuffer.append(eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); - stringBuffer.append(StringUtils.firstUpperCase(eStructuralFeature.getName())); - stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); - stringBuffer.append(TEXT_46); - - } -if (eClass.getEAnnotation("nodatabase") == null) { - - stringBuffer.append(TEXT_47); - } - stringBuffer.append(TEXT_48); - if (hasLists) { - importManager.getImport("java.util.List"); - - stringBuffer.append(TEXT_49); - } - stringBuffer.append(TEXT_50); - - for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { - if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDate()) { - importManager.getImport("java.util.Date"); - } else if (eStructuralFeature.getEType().getName().equals("DataHandler")) { - importManager.getImport("javax.activation.DataHandler"); - - } - boolean useId = (eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null); - - stringBuffer.append(TEXT_51); - stringBuffer.append(eStructuralFeature.getName()); - stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); - stringBuffer.append(TEXT_52); - stringBuffer.append(StringUtils.firstUpperCase(eStructuralFeature.getName())); - stringBuffer.append(useId ? "Id" : "" ); - stringBuffer.append(TEXT_53); - stringBuffer.append(GenerateUtils.getType(eStructuralFeature)); - stringBuffer.append(TEXT_54); - - } -if (eClass.getEAnnotation("nodatabase") == null) { - - stringBuffer.append(TEXT_55); - } - stringBuffer.append(TEXT_56); - - - for (EStructuralFeature eStructuralFeature : eClass.getEStructuralFeatures()) { - if (eStructuralFeature.getEAnnotation("notinserviceinterface") == null) { - if (eStructuralFeature instanceof EAttribute) { - EAttribute eAttribute = (EAttribute)eStructuralFeature; - if (eAttribute.getEType() instanceof EEnum) { - - stringBuffer.append(TEXT_57); - stringBuffer.append(eAttribute.getEType().getName()); - stringBuffer.append(TEXT_58); - stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); - stringBuffer.append(TEXT_59); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_60); - stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); - stringBuffer.append(TEXT_61); - stringBuffer.append(eAttribute.getEType().getName()); - stringBuffer.append(TEXT_62); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_63); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_64); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_65); - - } else { - if (eAttribute.isMany()) { - - stringBuffer.append(TEXT_66); - stringBuffer.append(eAttribute.getEType().getInstanceClassName()); - stringBuffer.append(TEXT_67); - stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); - stringBuffer.append(TEXT_68); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_69); - stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); - stringBuffer.append(TEXT_70); - stringBuffer.append(eAttribute.getEType().getInstanceClassName()); - stringBuffer.append(TEXT_71); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_72); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_73); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_74); - - } else { - if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray() && eAttribute.getEAnnotation("file") != null) { - - stringBuffer.append(TEXT_75); - stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); - stringBuffer.append(TEXT_76); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_77); - stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); - stringBuffer.append(TEXT_78); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_79); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_80); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_81); - - } else { - - stringBuffer.append(TEXT_82); - stringBuffer.append(eAttribute.getEType().getInstanceClassName()); - stringBuffer.append(TEXT_83); - stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); - stringBuffer.append(TEXT_84); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_85); - stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); - stringBuffer.append(TEXT_86); - stringBuffer.append(eAttribute.getEType().getInstanceClassName()); - stringBuffer.append(TEXT_87); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_88); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_89); - stringBuffer.append(eAttribute.getName()); - stringBuffer.append(TEXT_90); - - } - } - } - } else if (eStructuralFeature instanceof EReference) { - EReference eReference = (EReference)eStructuralFeature; - if (eReference.isMany()) { - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_91); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_92); - stringBuffer.append(GenerateUtils.makeGetter(eReference)); - stringBuffer.append(TEXT_93); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_94); - stringBuffer.append(GenerateUtils.makeSetter(eReference)); - stringBuffer.append(TEXT_95); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_96); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_97); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_98); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_99); - - } else { - - stringBuffer.append(TEXT_100); - stringBuffer.append(GenerateUtils.makeGetter(eReference)); - stringBuffer.append(TEXT_101); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_102); - stringBuffer.append(GenerateUtils.makeSetter(eReference)); - stringBuffer.append(TEXT_103); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_104); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_105); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_106); - - } - } else { - if (eReference.getEAnnotation("embedsreference") != null) { - - stringBuffer.append(TEXT_107); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_108); - stringBuffer.append(GenerateUtils.makeGetter(eReference)); - stringBuffer.append(TEXT_109); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_110); - stringBuffer.append(GenerateUtils.makeSetter(eReference)); - stringBuffer.append(TEXT_111); - stringBuffer.append(eReference.getEType().getName()); - stringBuffer.append(TEXT_112); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_113); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_114); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_115); - - } else { - - stringBuffer.append(TEXT_116); - stringBuffer.append(GenerateUtils.makeGetter(eReference)); - stringBuffer.append(TEXT_117); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_118); - stringBuffer.append(GenerateUtils.makeSetter(eReference)); - stringBuffer.append(TEXT_119); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_120); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_121); - stringBuffer.append(eReference.getName()); - stringBuffer.append(TEXT_122); - - } - } - } - } - } -if (eClass.getEAnnotation("nodatabase") == null) { - - stringBuffer.append(TEXT_123); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_124); - stringBuffer.append(eClass.getName()); - stringBuffer.append(TEXT_125); - -} - } else if (eClassifier instanceof EEnum) { - EEnum eEnum = (EEnum)eClassifier; - - stringBuffer.append(TEXT_126); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_127); - - for (EEnumLiteral eEnumLiteral : eEnum.getELiterals()) { - - stringBuffer.append(TEXT_128); - stringBuffer.append(eEnumLiteral.getName()); - stringBuffer.append(TEXT_129); - stringBuffer.append(eEnumLiteral.getValue()); - stringBuffer.append(TEXT_130); - stringBuffer.append(eEnum.getELiterals().get(eEnum.getELiterals().size()-1) == eEnumLiteral ? ";" : ","); - - } - - stringBuffer.append(TEXT_131); - stringBuffer.append(eEnum.getName()); - stringBuffer.append(TEXT_132); - } - - importManager.writeImports(stringBuffer); - - stringBuffer.append(TEXT_133); - return stringBuffer.toString(); - } -} +package org.bimserver.tools.generators; + +import org.eclipse.emf.ecore.*; +import org.bimserver.utils.*; +import org.bimserver.emf.MetaDataManager; +import java.io.File; +import org.bimserver.utils.StringUtils; + +public class ServiceInterfaceObjectGenerator +{ + protected static String nl; + public static synchronized ServiceInterfaceObjectGenerator create(String lineSeparator) + { + nl = lineSeparator; + ServiceInterfaceObjectGenerator result = new ServiceInterfaceObjectGenerator(); + nl = null; + return result; + } + + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = "package org.bimserver.interfaces.objects;"; + protected final String TEXT_2 = NL; + protected final String TEXT_3 = NL; + protected final String TEXT_4 = NL; + protected final String TEXT_5 = NL + NL + "@XmlRootElement"; + protected final String TEXT_6 = NL + "@XmlSeeAlso(value={"; + protected final String TEXT_7 = "S"; + protected final String TEXT_8 = ".class"; + protected final String TEXT_9 = ", "; + protected final String TEXT_10 = "})"; + protected final String TEXT_11 = NL + "public class S"; + protected final String TEXT_12 = " extends "; + protected final String TEXT_13 = "S"; + protected final String TEXT_14 = " implements "; + protected final String TEXT_15 = NL + "{"; + protected final String TEXT_16 = NL + "\tprivate long oid = -1;" + NL + "\tprivate int rid = 0;"; + protected final String TEXT_17 = NL + NL + "\t@XmlTransient" + NL + "\tprivate static SClass sClass;"; + protected final String TEXT_18 = NL + "\tprivate S"; + protected final String TEXT_19 = " "; + protected final String TEXT_20 = ";"; + protected final String TEXT_21 = NL + "\tprivate List<"; + protected final String TEXT_22 = "> "; + protected final String TEXT_23 = " = new ArrayList<"; + protected final String TEXT_24 = ">();"; + protected final String TEXT_25 = NL + "\t@XmlMimeType(\"application/octet-stream\")" + NL + "\tprivate DataHandler "; + protected final String TEXT_26 = ";"; + protected final String TEXT_27 = NL + "\tprivate "; + protected final String TEXT_28 = " "; + protected final String TEXT_29 = ";"; + protected final String TEXT_30 = NL + "\tprivate List "; + protected final String TEXT_35 = " = new ArrayList();"; + protected final String TEXT_36 = NL + "\tprivate S"; + protected final String TEXT_37 = " "; + protected final String TEXT_38 = ";"; + protected final String TEXT_39 = NL + "\tprivate long "; + protected final String TEXT_40 = "Id = -1;"; + protected final String TEXT_41 = NL + NL + "\tpublic long getOid() {" + NL + "\t\treturn this.oid;" + NL + "\t}" + NL + "" + NL + "\tpublic void setOid(long oid) {" + NL + "\t\tthis.oid = oid;" + NL + "\t}" + NL + "" + NL + "\tpublic int getRid() {" + NL + "\t\treturn rid;" + NL + "\t}" + NL + "\t" + NL + "\tpublic void setRid(int rid) {" + NL + "\t\tthis.rid = rid;" + NL + "\t}"; + protected final String TEXT_42 = NL + "\t" + NL + "\t@XmlTransient" + NL + "\tpublic SClass getSClass() {" + NL + "\t\treturn sClass;" + NL + "\t}" + NL + "\t" + NL + "\tpublic static void setSClass(SClass sClass) {" + NL + "\t\tS"; + protected final String TEXT_43 = ".sClass = sClass;" + NL + "\t}" + NL + "" + NL + "\tpublic Object sGet(SField sField) {"; + protected final String TEXT_44 = NL + "\t\tif (sField.getName().equals(\""; + protected final String TEXT_45 = "\")) {" + NL + "\t\t\treturn "; + protected final String TEXT_46 = "();" + NL + "\t\t}"; + protected final String TEXT_47 = NL + "\t\tif (sField.getName().equals(\"oid\")) {" + NL + "\t\t\treturn getOid();" + NL + "\t\t}" + NL + "\t\tif (sField.getName().equals(\"rid\")) {" + NL + "\t\t\treturn getRid();" + NL + "\t\t}"; + protected final String TEXT_48 = NL + "\t\tthrow new RuntimeException(\"Field \" + sField.getName() + \" not found\");" + NL + "\t}"; + protected final String TEXT_49 = NL + "\t@SuppressWarnings(\"unchecked\")"; + protected final String TEXT_50 = NL + NL + "\tpublic void sSet(SField sField, Object val) {"; + protected final String TEXT_51 = NL + "\t\tif (sField.getName().equals(\""; + protected final String TEXT_52 = "\")) {" + NL + "\t\t\tset"; + protected final String TEXT_53 = "(("; + protected final String TEXT_54 = ")val);" + NL + "\t\t\treturn;" + NL + "\t\t}"; + protected final String TEXT_55 = NL + "\t\tif (sField.getName().equals(\"oid\")) {" + NL + "\t\t\tsetOid((Long)val);" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tif (sField.getName().equals(\"rid\")) {" + NL + "\t\t\tsetRid((Integer)val);" + NL + "\t\t\treturn;" + NL + "\t\t}"; + protected final String TEXT_56 = NL + "\t\tthrow new RuntimeException(\"Field \" + sField.getName() + \" not found\");" + NL + "\t}" + NL + "\t"; + protected final String TEXT_57 = NL + "\tpublic S"; + protected final String TEXT_58 = " "; + protected final String TEXT_59 = "() {" + NL + "\t\treturn "; + protected final String TEXT_60 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; + protected final String TEXT_61 = "(S"; + protected final String TEXT_62 = " "; + protected final String TEXT_63 = ") {" + NL + "\t\tthis."; + protected final String TEXT_64 = " = "; + protected final String TEXT_65 = ";" + NL + "\t}" + NL + "\t"; + protected final String TEXT_66 = NL + NL + "\tpublic List<"; + protected final String TEXT_67 = "> "; + protected final String TEXT_68 = "() {" + NL + "\t\treturn "; + protected final String TEXT_69 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; + protected final String TEXT_70 = "(List<"; + protected final String TEXT_71 = "> "; + protected final String TEXT_72 = ") {" + NL + "\t\tthis."; + protected final String TEXT_73 = " = "; + protected final String TEXT_74 = ";" + NL + "\t}" + NL + "\t"; + protected final String TEXT_75 = NL + "\tpublic DataHandler "; + protected final String TEXT_76 = "() {" + NL + "\t\treturn "; + protected final String TEXT_77 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; + protected final String TEXT_78 = "(DataHandler "; + protected final String TEXT_79 = ") {" + NL + "\t\tthis."; + protected final String TEXT_80 = " = "; + protected final String TEXT_81 = ";" + NL + "\t}" + NL + "\t"; + protected final String TEXT_82 = NL + "\tpublic "; + protected final String TEXT_83 = " "; + protected final String TEXT_84 = "() {" + NL + "\t\treturn "; + protected final String TEXT_85 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; + protected final String TEXT_86 = "("; + protected final String TEXT_87 = " "; + protected final String TEXT_88 = ") {" + NL + "\t\tthis."; + protected final String TEXT_89 = " = "; + protected final String TEXT_90 = ";" + NL + "\t}" + NL + "\t"; + protected final String TEXT_91 = NL + "\tpublic List "; + protected final String TEXT_101 = "() {" + NL + "\t\treturn "; + protected final String TEXT_102 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; + protected final String TEXT_103 = "(List "; + protected final String TEXT_104 = ") {" + NL + "\t\tthis."; + protected final String TEXT_105 = " = "; + protected final String TEXT_106 = ";" + NL + "\t}" + NL + "\t"; + protected final String TEXT_107 = NL + "\tpublic S"; + protected final String TEXT_108 = " "; + protected final String TEXT_109 = "() {" + NL + "\t\treturn "; + protected final String TEXT_110 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void "; + protected final String TEXT_111 = "(S"; + protected final String TEXT_112 = " "; + protected final String TEXT_113 = ") {" + NL + "\t\tthis."; + protected final String TEXT_114 = " = "; + protected final String TEXT_115 = ";" + NL + "\t}" + NL + "\t" + NL + "\t"; + protected final String TEXT_116 = NL + "\tpublic long "; + protected final String TEXT_117 = "() {" + NL + "\t\treturn "; + protected final String TEXT_118 = "Id;" + NL + "\t}" + NL + "" + NL + "\tpublic void "; + protected final String TEXT_119 = "(long "; + protected final String TEXT_120 = "Id) {" + NL + "\t\tthis."; + protected final String TEXT_121 = "Id = "; + protected final String TEXT_122 = "Id;" + NL + "\t}" + NL + "\t"; + protected final String TEXT_123 = NL + "\t@Override" + NL + "\tpublic int hashCode() {" + NL + "\t\tfinal int prime = 31;" + NL + "\t\tint result = 1;" + NL + "\t\tresult = prime * result + (int) (oid ^ (oid >>> 32));" + NL + "\t\treturn result;" + NL + "\t}" + NL + "" + NL + "\t@Override" + NL + "\tpublic boolean equals(Object obj) {" + NL + "\t\tif (this == obj)" + NL + "\t\t\treturn true;" + NL + "\t\tif (obj == null)" + NL + "\t\t\treturn false;" + NL + "\t\tif (getClass() != obj.getClass())" + NL + "\t\t\treturn false;" + NL + "\t\tS"; + protected final String TEXT_124 = " other = (S"; + protected final String TEXT_125 = ") obj;" + NL + "\t\tif (oid != other.oid)" + NL + "\t\t\treturn false;" + NL + "\t\treturn true;" + NL + "\t}"; + protected final String TEXT_126 = NL + "public enum S"; + protected final String TEXT_127 = " {"; + protected final String TEXT_128 = NL + "\t"; + protected final String TEXT_129 = "("; + protected final String TEXT_130 = ")"; + protected final String TEXT_131 = NL + "\tint ordinal;" + NL + "" + NL + "\tS"; + protected final String TEXT_132 = "(int ordinal) {" + NL + "\t\tthis.ordinal = ordinal;" + NL + "\t}" + NL + "\t" + NL + "\tpublic int getOrdinal() {" + NL + "\t\treturn ordinal;" + NL + "\t}"; + protected final String TEXT_133 = NL + "}"; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(TEXT_1); + +/****************************************************************************** + * Copyright (C) 2009-2012 BIMserver.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + *****************************************************************************/ + + stringBuffer.append(TEXT_2); + stringBuffer.append(TEXT_3); + stringBuffer.append(Licenser.getCommentedLicenseText(new File("license.txt"))); + stringBuffer.append(TEXT_4); + + Object[] arguments = (Object[])argument; + EClassifier eClassifier = (EClassifier)arguments[0]; + ImportManager importManager = (ImportManager)arguments[1]; + MetaDataManager metaDataManager = (MetaDataManager)arguments[2]; + importManager.mark(stringBuffer); + boolean hasLists = false; + if (eClassifier instanceof EClass) { + EClass eClass = (EClass)eClassifier; + for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { + if (eStructuralFeature.isMany()) { + hasLists = true; + break; + } + } + + importManager.getImport("javax.xml.bind.annotation.XmlRootElement"); + importManager.getImport("org.bimserver.shared.meta.*"); + + stringBuffer.append(TEXT_5); + +importManager.getImport("javax.xml.bind.annotation.XmlTransient"); +if (metaDataManager.getPackageMetaData(eClassifier.getEPackage().getName()).getDirectSubClasses(eClass) != null && !metaDataManager.getPackageMetaData(eClassifier.getEPackage().getName()).getDirectSubClasses(eClass).isEmpty()) { +importManager.getImport("javax.xml.bind.annotation.XmlSeeAlso"); + + stringBuffer.append(TEXT_6); + +java.util.Set subClasses = metaDataManager.getPackageMetaData(eClassifier.getEPackage().getName()).getDirectSubClasses(eClass); +int i=0; +for (EClass subClass : subClasses) { + + stringBuffer.append(TEXT_7); + stringBuffer.append(subClass.getName()); + stringBuffer.append(TEXT_8); + + if (i != subClasses.size() - 1) { + + stringBuffer.append(TEXT_9); + + } + i++; +} + stringBuffer.append(TEXT_10); + +} + + stringBuffer.append(TEXT_11); + stringBuffer.append(eClass.getName()); + + if (!eClass.getESuperTypes().isEmpty()) { + + stringBuffer.append(TEXT_12); + + for (EClass eSuperClass : eClass.getESuperTypes()) { + + stringBuffer.append(TEXT_13); + stringBuffer.append(eSuperClass.getName()); + + } + } + + stringBuffer.append(TEXT_14); + stringBuffer.append( eClass.getEAnnotation("nodatabase") != null ? "SBase" : "SDataBase" ); + stringBuffer.append(TEXT_15); + if (eClass.getEAnnotation("nodatabase") == null) { + stringBuffer.append(TEXT_16); + } + stringBuffer.append(TEXT_17); + + for (EStructuralFeature eStructuralFeature : eClass.getEStructuralFeatures()) { + if (eStructuralFeature.getEAnnotation("notinserviceinterface") == null) { + if (eStructuralFeature instanceof EAttribute) { + EAttribute eAttribute = (EAttribute)eStructuralFeature; + if (eAttribute.getEType() instanceof EEnum) { + + stringBuffer.append(TEXT_18); + stringBuffer.append(eAttribute.getEType().getName()); + stringBuffer.append(TEXT_19); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_20); + + } else { + if (eAttribute.isMany()) { + importManager.getImport("java.util.List"); + importManager.getImport("java.util.ArrayList"); + + stringBuffer.append(TEXT_21); + stringBuffer.append(eAttribute.getEType().getInstanceClassName()); + stringBuffer.append(TEXT_22); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_23); + stringBuffer.append(eAttribute.getEType().getInstanceClassName()); + stringBuffer.append(TEXT_24); + + } else { + if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray() && eAttribute.getEAnnotation("file") != null) { + importManager.getImport("javax.activation.DataHandler"); + + stringBuffer.append(TEXT_25); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_26); + + } else { + + stringBuffer.append(TEXT_27); + stringBuffer.append(eAttribute.getEType().getInstanceClassName()); + stringBuffer.append(TEXT_28); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_29); + + } + } + } + } else if (eStructuralFeature instanceof EReference) { + EReference eReference = (EReference)eStructuralFeature; + if (eReference.isMany()) { + importManager.getImport("java.util.List"); + importManager.getImport("java.util.ArrayList"); + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_30); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_31); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_32); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_33); + + } else { + + stringBuffer.append(TEXT_34); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_35); + + } + } else { + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_36); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_37); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_38); + + } else { + + stringBuffer.append(TEXT_39); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_40); + + } + } + } + } + } + + if (eClass.getEAnnotation("nodatabase") == null) { + stringBuffer.append(TEXT_41); + } + stringBuffer.append(TEXT_42); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_43); + + for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { + + stringBuffer.append(TEXT_44); + stringBuffer.append(eStructuralFeature.getName()); + stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); + stringBuffer.append(TEXT_45); + stringBuffer.append(eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); + stringBuffer.append(StringUtils.firstUpperCase(eStructuralFeature.getName())); + stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); + stringBuffer.append(TEXT_46); + + } +if (eClass.getEAnnotation("nodatabase") == null) { + + stringBuffer.append(TEXT_47); + } + stringBuffer.append(TEXT_48); + if (hasLists) { + importManager.getImport("java.util.List"); + + stringBuffer.append(TEXT_49); + } + stringBuffer.append(TEXT_50); + + for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { + if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDate()) { + importManager.getImport("java.util.Date"); + } else if (eStructuralFeature.getEType().getName().equals("DataHandler")) { + importManager.getImport("javax.activation.DataHandler"); + + } + boolean useId = (eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null); + + stringBuffer.append(TEXT_51); + stringBuffer.append(eStructuralFeature.getName()); + stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); + stringBuffer.append(TEXT_52); + stringBuffer.append(StringUtils.firstUpperCase(eStructuralFeature.getName())); + stringBuffer.append(useId ? "Id" : "" ); + stringBuffer.append(TEXT_53); + stringBuffer.append(GenerateUtils.getType(eStructuralFeature)); + stringBuffer.append(TEXT_54); + + } +if (eClass.getEAnnotation("nodatabase") == null) { + + stringBuffer.append(TEXT_55); + } + stringBuffer.append(TEXT_56); + + + for (EStructuralFeature eStructuralFeature : eClass.getEStructuralFeatures()) { + if (eStructuralFeature.getEAnnotation("notinserviceinterface") == null) { + if (eStructuralFeature instanceof EAttribute) { + EAttribute eAttribute = (EAttribute)eStructuralFeature; + if (eAttribute.getEType() instanceof EEnum) { + + stringBuffer.append(TEXT_57); + stringBuffer.append(eAttribute.getEType().getName()); + stringBuffer.append(TEXT_58); + stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); + stringBuffer.append(TEXT_59); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_60); + stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); + stringBuffer.append(TEXT_61); + stringBuffer.append(eAttribute.getEType().getName()); + stringBuffer.append(TEXT_62); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_63); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_64); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_65); + + } else { + if (eAttribute.isMany()) { + + stringBuffer.append(TEXT_66); + stringBuffer.append(eAttribute.getEType().getInstanceClassName()); + stringBuffer.append(TEXT_67); + stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); + stringBuffer.append(TEXT_68); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_69); + stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); + stringBuffer.append(TEXT_70); + stringBuffer.append(eAttribute.getEType().getInstanceClassName()); + stringBuffer.append(TEXT_71); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_72); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_73); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_74); + + } else { + if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray() && eAttribute.getEAnnotation("file") != null) { + + stringBuffer.append(TEXT_75); + stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); + stringBuffer.append(TEXT_76); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_77); + stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); + stringBuffer.append(TEXT_78); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_79); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_80); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_81); + + } else { + + stringBuffer.append(TEXT_82); + stringBuffer.append(eAttribute.getEType().getInstanceClassName()); + stringBuffer.append(TEXT_83); + stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); + stringBuffer.append(TEXT_84); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_85); + stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); + stringBuffer.append(TEXT_86); + stringBuffer.append(eAttribute.getEType().getInstanceClassName()); + stringBuffer.append(TEXT_87); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_88); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_89); + stringBuffer.append(eAttribute.getName()); + stringBuffer.append(TEXT_90); + + } + } + } + } else if (eStructuralFeature instanceof EReference) { + EReference eReference = (EReference)eStructuralFeature; + if (eReference.isMany()) { + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_91); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_92); + stringBuffer.append(GenerateUtils.makeGetter(eReference)); + stringBuffer.append(TEXT_93); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_94); + stringBuffer.append(GenerateUtils.makeSetter(eReference)); + stringBuffer.append(TEXT_95); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_96); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_97); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_98); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_99); + + } else { + + stringBuffer.append(TEXT_100); + stringBuffer.append(GenerateUtils.makeGetter(eReference)); + stringBuffer.append(TEXT_101); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_102); + stringBuffer.append(GenerateUtils.makeSetter(eReference)); + stringBuffer.append(TEXT_103); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_104); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_105); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_106); + + } + } else { + if (eReference.getEAnnotation("embedsreference") != null) { + + stringBuffer.append(TEXT_107); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_108); + stringBuffer.append(GenerateUtils.makeGetter(eReference)); + stringBuffer.append(TEXT_109); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_110); + stringBuffer.append(GenerateUtils.makeSetter(eReference)); + stringBuffer.append(TEXT_111); + stringBuffer.append(eReference.getEType().getName()); + stringBuffer.append(TEXT_112); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_113); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_114); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_115); + + } else { + + stringBuffer.append(TEXT_116); + stringBuffer.append(GenerateUtils.makeGetter(eReference)); + stringBuffer.append(TEXT_117); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_118); + stringBuffer.append(GenerateUtils.makeSetter(eReference)); + stringBuffer.append(TEXT_119); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_120); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_121); + stringBuffer.append(eReference.getName()); + stringBuffer.append(TEXT_122); + + } + } + } + } + } +if (eClass.getEAnnotation("nodatabase") == null) { + + stringBuffer.append(TEXT_123); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_124); + stringBuffer.append(eClass.getName()); + stringBuffer.append(TEXT_125); + +} + } else if (eClassifier instanceof EEnum) { + EEnum eEnum = (EEnum)eClassifier; + + stringBuffer.append(TEXT_126); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_127); + + for (EEnumLiteral eEnumLiteral : eEnum.getELiterals()) { + + stringBuffer.append(TEXT_128); + stringBuffer.append(eEnumLiteral.getName()); + stringBuffer.append(TEXT_129); + stringBuffer.append(eEnumLiteral.getValue()); + stringBuffer.append(TEXT_130); + stringBuffer.append(eEnum.getELiterals().get(eEnum.getELiterals().size()-1) == eEnumLiteral ? ";" : ","); + + } + + stringBuffer.append(TEXT_131); + stringBuffer.append(eEnum.getName()); + stringBuffer.append(TEXT_132); + } + + importManager.writeImports(stringBuffer); + + stringBuffer.append(TEXT_133); + return stringBuffer.toString(); + } +} diff --git a/Shared/.classpath b/Shared/.classpath index 03fdf67423..37e72dd135 100644 --- a/Shared/.classpath +++ b/Shared/.classpath @@ -47,7 +47,6 @@ - diff --git a/Shared/lib/other/truevfs-profile-default-0.11.0-all.jar b/Shared/lib/other/truevfs-profile-default-0.11.0-all.jar deleted file mode 100644 index b228db369c..0000000000 Binary files a/Shared/lib/other/truevfs-profile-default-0.11.0-all.jar and /dev/null differ