diff options
Diffstat (limited to 'bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp')
17 files changed, 0 insertions, 2110 deletions
diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileAttributeGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileAttributeGenerator.java deleted file mode 100644 index 1225e0324..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileAttributeGenerator.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060612 145433 gilberta@ca.ibm.com - Gilbert Andrews - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.TypeVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.AttributeElementType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; - - -/** -* Objects of this class represent a InputFileTypeGenerator. -* */ -public class InputFileAttributeGenerator extends InputFileTypeGenerator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private boolean fStateLess; - - /** - * Constructor. - * - */ - public InputFileAttributeGenerator (StringBuffer buffer, int currentLevel, int levelsDeep) - { - super(buffer,currentLevel,levelsDeep); - } - - - /* - * Takes in an object to be acted upon by this visitor action - * @param Object The object to be acted upon - */ - public IStatus visit (Object object) - { - - AttributeElementType attributeElementType = (AttributeElementType)object; - //if it is a bean is it stateless - attributeElementType.getTypeElement(); - if(attributeElementType.getSetterMethod() == null) return Status.OK_STATUS; - if(attributeElementType.getTypeElement().isBean()){ - BeanElement bean = (BeanElement)attributeElementType.getTypeElement(); - fStateLess = bean.isStateLess(); - } - - TypeVisitor typeVisitor = new TypeVisitor(); - InputFileTypeGenerator inputFileTypeGenerator = new InputFileTypeGenerator(fbuffer,fCurrentLevel,fLevelsDeep); - if(attributeElementType.getTypeElement().isBean() && !TypeFactory.recognizedBean(attributeElementType.getTypeElement().getName()) - && !(getReturnParam() && (TypeFactory.isRecognizedReturnType(attributeElementType.getTypeElement().getTypeName()) || fStateLess))) - - addParentGetter(attributeElementType.getGetterMethod(),attributeElementType.getTypeElement().getName()); - inputFileTypeGenerator.addParentGetter(returnParentGetter(),returnParentGetterType()); - inputFileTypeGenerator.setInstanceName(fInstanceName); - inputFileTypeGenerator.setReturnParam(getReturnParam()); - typeVisitor.run(attributeElementType,inputFileTypeGenerator); - fbuffer = inputFileTypeGenerator.getStringBuffer(); - - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileGenerator.java deleted file mode 100644 index 6d47bb0ba..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileGenerator.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.MethodVisitor; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a MethodFilegenerator. -* */ -public class InputFileGenerator extends Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - public String fResultName; - - /** - * Constructor. - * used directly - */ - public InputFileGenerator (String result) - { - super(); - fResultName = result; - } - - /** - * Constructor. - * called from subclasses - */ - public InputFileGenerator (StringBuffer buffer, String result) - { - super(buffer); - fResultName = result; - } - - /** - * Constructor. - * called from subclasses - */ - public InputFileGenerator (StringBuffer buffer) - { - super(buffer); - } - - public void setFileNames(String results) - { - fResultName = results; - } - - //takes in a bean node - public IStatus visit (Object object) - { - Element beanElement = (Element)object; - fbuffer.append("<%@page contentType=\"text/html;charset=UTF-8\"%>" + StringUtils.NEWLINE); - fbuffer.append("<HTML>" + StringUtils.NEWLINE); - fbuffer.append("<HEAD>" + StringUtils.NEWLINE); - fbuffer.append("<TITLE>Inputs</TITLE>" + StringUtils.NEWLINE); - fbuffer.append("</HEAD>" + StringUtils.NEWLINE); - fbuffer.append("<BODY>" + StringUtils.NEWLINE); - fbuffer.append("<H1>Inputs</H1>" + StringUtils.NEWLINE + "" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE + "String method = request.getParameter(\"method\");" + StringUtils.NEWLINE); - fbuffer.append("int methodID = 0;" + StringUtils.NEWLINE); - fbuffer.append("if (method == null) methodID = -1;" + StringUtils.NEWLINE + "" + StringUtils.NEWLINE); - fbuffer.append("boolean valid = true;" + StringUtils.NEWLINE + StringUtils.NEWLINE); - - fbuffer.append("if(methodID != -1) methodID = Integer.parseInt(method);" + StringUtils.NEWLINE); - fbuffer.append("switch (methodID){ " + StringUtils.NEWLINE); - - // go to the next generator - MethodVisitor methodVisitor = new MethodVisitor(); - InputFileHelp1Generator inputFileHelp1Generator = new InputFileHelp1Generator(fbuffer,fResultName); - methodVisitor.run(beanElement,inputFileHelp1Generator); - fbuffer = inputFileHelp1Generator.getStringBuffer(); - - fbuffer.append("case 1111111111:" + StringUtils.NEWLINE); - fbuffer.append("valid = false;" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("<FORM METHOD=\"POST\" ACTION=\"" + fResultName + "\" TARGET=\"result\">" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"HIDDEN\" NAME=\"method\" VALUE=\"<%=method%>\">" + StringUtils.NEWLINE); - fbuffer.append("<TABLE>" + StringUtils.NEWLINE); - fbuffer.append("<TR>" + StringUtils.NEWLINE); - fbuffer.append("<TD COLSPAN=\"1\" ALIGN=\"LEFT\">URLString:</TD>" + StringUtils.NEWLINE); - fbuffer.append("<TD ALIGN=\"left\"><INPUT TYPE=\"TEXT\" NAME=\"url1111111111\" SIZE=20></TD>" + StringUtils.NEWLINE); - fbuffer.append("</TR>" + StringUtils.NEWLINE); - fbuffer.append("</TABLE>" + StringUtils.NEWLINE); - fbuffer.append("<BR>" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"SUBMIT\" VALUE=\"Invoke\">" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"RESET\" VALUE=\"Clear\">" + StringUtils.NEWLINE); - fbuffer.append("</FORM>" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("break;" + StringUtils.NEWLINE); - fbuffer.append("case 1111111112:" + StringUtils.NEWLINE); - fbuffer.append("valid = false;" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("<FORM METHOD=\"POST\" ACTION=\"" + fResultName + "\" TARGET=\"result\">" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"HIDDEN\" NAME=\"method\" VALUE=\"<%=method%>\">" + StringUtils.NEWLINE); - fbuffer.append("<BR>" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"SUBMIT\" VALUE=\"Invoke\">" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"RESET\" VALUE=\"Clear\">" + StringUtils.NEWLINE); - fbuffer.append("</FORM>" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("break;" + StringUtils.NEWLINE); - - - - fbuffer.append("}" + StringUtils.NEWLINE); - fbuffer.append("if (valid) {" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE + "Select a method to test." + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append(Generator.TAB + "return;" + StringUtils.NEWLINE); - fbuffer.append("}" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE + StringUtils.NEWLINE); - fbuffer.append("</BODY>" + StringUtils.NEWLINE); - fbuffer.append("</HTML>" + StringUtils.NEWLINE); - - return Status.OK_STATUS; - - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileHelp1Generator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileHelp1Generator.java deleted file mode 100644 index c46105fec..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileHelp1Generator.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.ParameterVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.MethodElement; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a InputFileHelp1Generator. -* */ -public class InputFileHelp1Generator extends InputFileGenerator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - public static final int INITIAL_STATE = 1; - public static final int FINAL_STATE = 2; - - public int fstate; - - /** - * Constructor. - * - */ - public InputFileHelp1Generator (StringBuffer buffer) - { - super(buffer); - fstate = INITIAL_STATE; - } - - /** - * Constructor. - * - */ - public InputFileHelp1Generator (StringBuffer buffer,String resultName) - { - super(buffer,resultName); - fstate = INITIAL_STATE; - } - - /* - * Takes in an element - * @param Object Takes in an object to be acted upon - */ - public IStatus visit (Object object) - { - Element methodElement = (Element)object; - MethodElement method = (MethodElement)methodElement; - if (method.getMethodOmmission()) return Status.OK_STATUS; - - ParameterVisitor parameterVisitor = new ParameterVisitor(); - fbuffer.append("case " + method.getNumberID()+ ":" + StringUtils.NEWLINE); - fbuffer.append("valid = false;" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("<FORM METHOD=\"POST\" ACTION=\"" + fResultName + "\" TARGET=\"result\">" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"HIDDEN\" NAME=\"method\" VALUE=\"<%=method%>\">" + StringUtils.NEWLINE); - - // go to the next generator - InputFileHelp2Generator inputFileHelp2Generator = new InputFileHelp2Generator(fbuffer); - parameterVisitor.run(methodElement,inputFileHelp2Generator); - fbuffer = inputFileHelp2Generator.getStringBuffer(); - - fbuffer.append("<BR>" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"SUBMIT\" VALUE=\"Invoke\">" + StringUtils.NEWLINE); - fbuffer.append("<INPUT TYPE=\"RESET\" VALUE=\"Clear\">" + StringUtils.NEWLINE); - fbuffer.append("</FORM>" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("break;" + StringUtils.NEWLINE); - - - return Status.OK_STATUS; - - - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileHelp2Generator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileHelp2Generator.java deleted file mode 100644 index 2b7e64b6e..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileHelp2Generator.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.TypeVisitor; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a InputFileHelp2Generator. -* */ -public class InputFileHelp2Generator extends InputFileHelp1Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /* - * This is actually used by the result generator to show the - * resultant Bean - * The name is the name the resultant bean is using as its instance name - */ - protected String fInstanceName; - private boolean fReturnParam=false; - - /** - * Constructor. - * - */ - public InputFileHelp2Generator (StringBuffer buffer) - { - super(buffer); - fInstanceName=""; - } - - /** - * This is state data to be used by the generators - * @param String name The instance name of the parameters type bean - */ - public void setInstanceName(String name) - { - fInstanceName = name; - } - - /** - * This is state data to be used by the generators - * @return String name The instance name of the parameters type bean - */ - public String getInstanceName() - { - return fInstanceName; - } - - - /* - * Takes in an object to be acted upon by this visitor action - * @param Object The object to be acted upon - */ - public IStatus visit (Object object) - { - Element parameterElement = (Element)object; - getVisitor(); - - fbuffer.append("<TABLE>" + StringUtils.NEWLINE); - - TypeVisitor typeVisitor = new TypeVisitor(); - InputFileTypeGenerator inputFileTypeGenerator = new InputFileTypeGenerator(fbuffer,0); - inputFileTypeGenerator.setReturnParam(getReturnParam()); - inputFileTypeGenerator.setInstanceName(fInstanceName); - typeVisitor.run(parameterElement,inputFileTypeGenerator); - fbuffer = inputFileTypeGenerator.getStringBuffer(); - - fbuffer.append("</TABLE>" + StringUtils.NEWLINE); - - return Status.OK_STATUS; - - } - - public boolean getReturnParam() - { - return fReturnParam; - } - - public void setReturnParam(boolean returnParam) - { - fReturnParam = returnParam; - } - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileTypeGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileTypeGenerator.java deleted file mode 100644 index 9b9bf6dc5..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/InputFileTypeGenerator.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060612 145433 gilberta@ca.ibm.com - Gilbert Andrews - * 20070410 180952 makandre@ca.ibm.com - Andrew Mak, Sample JSP generator chokes on interfaces and abstract classes - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import java.util.Vector; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.AttributeVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.FieldVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.AttributeElementType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.DataType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.SimpleElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; - - -/** -* Objects of this class represent a InputFileTypeGenerator. -* */ -public class InputFileTypeGenerator extends InputFileHelp2Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - protected String fParentGetters; - protected int fLevelsDeep; - protected int fColspan; - protected int fCurrentLevel; - private boolean fIsSimple; - private boolean fStateLessBean; - private Vector fGetters; - private Vector fTypes; - private boolean fWrite = true; - - /** - * Constructor. - * - */ - public InputFileTypeGenerator (StringBuffer buffer, int currentLevel) - { - super(buffer); - fCurrentLevel = currentLevel; - fLevelsDeep = -1; - fParentGetters = ""; - } - - /** - * Constructor. - * - */ - public InputFileTypeGenerator (StringBuffer buffer, int currentLevel,int levelsDeep) - { - super(buffer); - fCurrentLevel = currentLevel; - fLevelsDeep = levelsDeep; - fParentGetters = ""; - } - - public void setParentGetters(Vector getter,Vector type) - { - if(fGetters != null){ - fGetters.clear(); - fTypes.clear(); - } - addParentGetter(getter,type); - } - - - /** - * This function holds some state data that is important in getting the - * Strings for display of resultant beans - * @param String getter this is the getter of an attribute - * The idea is that by the time we get to the simple type - * we have getAddress().getStreet().... - */ - public void addParentGetter(String getter, String type) - { - if(fGetters == null) fGetters = new Vector(); - if(fTypes == null) fTypes = new Vector(); - fGetters.addElement(getter); - fTypes.addElement(type); - } - - /* - * this will be used when passing between two visitors - * - */ - public void addParentGetter(Vector getters, Vector types) - { - if(fGetters == null) fGetters = new Vector(); - if(fTypes == null) fTypes = new Vector(); - int size = getters.size(); - for(int i = 0; i<size; i++){ - fGetters.addElement(getters.get(i)); - fTypes.addElement(types.get(i)); - } - } - - protected String returnParentGetter(int count) - { - if (fGetters == null || count > fGetters.size()) return null; - return (String)fGetters.get(count); - } - - protected String returnParentGetterType(int count) - { - if (fTypes == null || count > fTypes.size()) return null; - return (String)fTypes.get(count); - } - - protected Vector returnParentGetter() - { - if (fGetters == null ) return new Vector(); - return fGetters; - } - - protected Vector returnParentGetterType() - { - if (fTypes == null ) return new Vector(); - return fTypes; - } - - protected int getterCount() - { - if(fGetters == null) return 0; - return fGetters.size(); - } - - - /** - * This function returns some state data that is important in getting the - * Strings for display of resultant beans - * @return String the string of getters to this point - * The idea is that by the time we get to the simple type - * we have getAddress().getStreet().... - */ - public String getParentGetters() - { - return fParentGetters; - } - - /* - * Takes in an object to be acted upon by this visitor action - * @param Object The object to be acted upon - */ - public IStatus visit (Object object) - { - TypeElement element = (TypeElement)object; - - if (Boolean.TRUE.equals(element.getPropertyAsObject(TypeElement.NON_INSTANTIABLE))) - return Status.OK_STATUS; - - if (element instanceof SimpleElement) fIsSimple = true; - else fIsSimple = false; - - //this could be a statelessbean need to know - if (element instanceof BeanElement ){ - BeanElement bean = (BeanElement)element; - if (bean.isStateLess()) fStateLessBean = true; - if (bean.getAttrib() == BeanElement.READONLY) fWrite = false; - } - - - - //Complex type support - //first I need to find out how many levels deep - if(fLevelsDeep == -1){ - AttributeVisitor attributeVisitor = new AttributeVisitor(); - LevelsDeepVisitorAction ldva = new LevelsDeepVisitorAction(); - attributeVisitor.run(element,ldva); - fLevelsDeep = ldva.getLevelsDeep(); - //check out the fields - FieldVisitor fieldVisitor = new FieldVisitor(); - LevelsDeepVisitorAction ldva2 = new LevelsDeepVisitorAction(); - fieldVisitor.run(element,ldva2); - - if(fLevelsDeep < ldva2.getLevelsDeep())fLevelsDeep = ldva2.getLevelsDeep(); - fLevelsDeep++; - } - fColspan = fLevelsDeep - fCurrentLevel; - - //if we have a return param with no getter make sure we are on the - //attribute and not the parameter then return - if(getReturnParam() && element.getOwningElement() instanceof AttributeElementType &&(((AttributeElementType)element.getOwningElement()).getGetterMethod() == null) ) return Status.OK_STATUS; - - //Code gen for all elements - if(fWrite){ - fbuffer.append("<TR>" + StringUtils.NEWLINE); - for (int i = 0; i < fCurrentLevel;i++){ - fbuffer.append("<TD WIDTH=\"5%\"></TD>" + StringUtils.NEWLINE); - } - fbuffer.append("<TD COLSPAN=\"" + fColspan + "\" ALIGN=\"LEFT\">" + element.getOwningElement().getName() + ":</TD>" + StringUtils.NEWLINE); - } - if(fIsSimple || TypeFactory.recognizedBean(element.getName()) - || (getReturnParam() && fStateLessBean) - || (getReturnParam() && TypeFactory.isRecognizedReturnType(element.getTypeName()))){ - if(getInstanceName().equals("")){ - if(fWrite){ - DataType dataType = TypeFactory.createType(element.getName(),element.getOwningElement().getMUID()); - fbuffer.append(dataType.inputForm(element.getOwningElement().getMUID())); - } - } - else{ - if(getReturnParam() && (TypeFactory.isRecognizedReturnType(element.getTypeName()) || fStateLessBean)){ - DataType dataType = TypeFactory.createType(element.getTypeName(),element.getOwningElement().getMUID()); - String uniqueName = "type" + dataType.getUniqueName(); - fbuffer.append("<TD>" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("if(" + getInstanceName() + " != null){" + StringUtils.NEWLINE); - String afterString = getInstanceName(); - String tmpString = "tebece"; - String prevString = getInstanceName(); - String newTmpString = ""; - for(int i=0;i<getterCount();i++){ - newTmpString = tmpString + i; - fbuffer.append(returnParentGetterType(i) + " " + newTmpString + "=" + prevString + "." + returnParentGetter(i) + ";" + StringUtils.NEWLINE); - prevString = newTmpString; - fbuffer.append("if(" + newTmpString + " != null){" + StringUtils.NEWLINE); - afterString = newTmpString; - } - fbuffer.append(element.getName() + " " + uniqueName + " = " + afterString + "." + ((AttributeElementType)element.getOwningElement()).getGetterMethod()+ ";" + StringUtils.NEWLINE); - fbuffer.append(dataType.TypeConversion(uniqueName)); - for(int i=0;i<getterCount();i++){ - fbuffer.append("}"); - } - fbuffer.append("}%>" + StringUtils.NEWLINE); - fbuffer.append("</TD>" + StringUtils.NEWLINE); - } - - else{ - fbuffer.append("<TD>" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("if(" + getInstanceName() + " != null){" + StringUtils.NEWLINE); - String afterString = getInstanceName(); - String tmpString = "tebece"; - String prevString = getInstanceName(); - String newTmpString = ""; - for(int i=0;i<getterCount();i++){ - newTmpString = tmpString + i; - fbuffer.append(returnParentGetterType(i) + " " + newTmpString + "=" + prevString + "." + returnParentGetter(i) + ";" + StringUtils.NEWLINE); - prevString = newTmpString; - fbuffer.append("if(" + newTmpString + " != null){" + StringUtils.NEWLINE); - afterString = newTmpString; - } - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("<%="); - fbuffer.append(afterString + "." + ((AttributeElementType)element.getOwningElement()).getGetterMethod()+ StringUtils.NEWLINE); - fbuffer.append("%>"); - fbuffer.append("<%"); - for(int i=0;i<getterCount();i++){ - fbuffer.append("}"); - } - fbuffer.append("}%>" + StringUtils.NEWLINE); - fbuffer.append("</TD>" + StringUtils.NEWLINE); - } - } - - } - - //Now carry on down the rest of the bean - else { - AttributeVisitor attributeVisitor = new AttributeVisitor(); - attributeVisitor.setResidentVector1(returnParentGetter()); - attributeVisitor.setResidentVector2(returnParentGetterType()); - InputFileAttributeGenerator inputFileAttributeGenerator = new InputFileAttributeGenerator(fbuffer,(fCurrentLevel + 1),fLevelsDeep); - inputFileAttributeGenerator.setReturnParam(getReturnParam()); - inputFileAttributeGenerator.setInstanceName(fInstanceName); - attributeVisitor.run(element,inputFileAttributeGenerator); - fbuffer = inputFileAttributeGenerator.getStringBuffer(); - - //now do fields very similar - FieldVisitor fieldVisitor = new FieldVisitor(); - fieldVisitor.setResidentVector1(returnParentGetter()); - fieldVisitor.setResidentVector2(returnParentGetterType()); - InputFileAttributeGenerator inputFileAttributeGenerator2 = new InputFileAttributeGenerator(fbuffer,(fCurrentLevel + 1),fLevelsDeep); - inputFileAttributeGenerator2.setReturnParam(getReturnParam()); - inputFileAttributeGenerator2.setInstanceName(fInstanceName); - fieldVisitor.run(element,inputFileAttributeGenerator2); - fbuffer = inputFileAttributeGenerator2.getStringBuffer(); - - - - } - - - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/LevelsDeepVisitorAction.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/LevelsDeepVisitorAction.java deleted file mode 100644 index 2f2e1a926..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/LevelsDeepVisitorAction.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.consumption.codegen.Visitor; -import org.eclipse.jst.ws.internal.consumption.codegen.VisitorAction; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.AttributeVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.FieldVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.TypeVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.AttributeElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a LevelsDeepVisitorAction. -* */ -public class LevelsDeepVisitorAction implements VisitorAction -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private int fLevelsDeep; - private int fDeepestLevel; - - /** - * Constructor. - * This is the starting point - * - */ - public LevelsDeepVisitorAction () - { - fLevelsDeep = 0; - } - - /** - * Constructor. - * This is the starting point - * - */ - public LevelsDeepVisitorAction (int current,boolean increment) - { - fLevelsDeep = current; - if(increment) fLevelsDeep++; - fDeepestLevel = fLevelsDeep; - } - - public void initialize(String resident) - { - //nothing to be done but must be implemented - } - - - - /** - * The visitor that called this VisitorAction - * @param visitor the visitor that called this visitor action - */ - public void setVisitor(Visitor visitor) - { - } - - - /** - * Returns the level of nesting within this bean - * @return int returns the int number representing the number of nests of this bean - */ - public int getLevelsDeep() - { - return fDeepestLevel; - } - - - /** - * Takes in an object to be acted upon by this visitor action - * @param Object The object to be acted upon - */ - public IStatus visit (Object object) - { - Element element = (Element)object; - if (element instanceof AttributeElement || element instanceof TypeElement){ - TypeVisitor typeVisitor = new TypeVisitor(); - LevelsDeepVisitorAction lvda = new LevelsDeepVisitorAction(fLevelsDeep,true); - typeVisitor.run(element,lvda); - - if (lvda.getLevelsDeep() > fDeepestLevel) fDeepestLevel = lvda.getLevelsDeep(); - - } - else if (element instanceof BeanElement && !(TypeFactory.recognizedBean(element.getName()))){ - AttributeVisitor attributeVisitor = new AttributeVisitor(); - LevelsDeepVisitorAction lvda = new LevelsDeepVisitorAction(fLevelsDeep,false); - attributeVisitor.run(element,lvda); - if (lvda.getLevelsDeep() > fDeepestLevel) fDeepestLevel = lvda.getLevelsDeep(); - - FieldVisitor fieldVisitor = new FieldVisitor(); - LevelsDeepVisitorAction lvda2 = new LevelsDeepVisitorAction(fLevelsDeep,false); - fieldVisitor.run(element,lvda2); - if (lvda2.getLevelsDeep() > fDeepestLevel) fDeepestLevel = lvda2.getLevelsDeep(); - - } - - return Status.OK_STATUS; - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/MethodFileGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/MethodFileGenerator.java deleted file mode 100644 index caec50e47..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/MethodFileGenerator.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.MethodVisitor; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a MethodFilegenerator. -* */ -public class MethodFileGenerator extends Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - public String fInputName; - /** - * Constructor. - * - */ - public MethodFileGenerator (String inputs) - { - super(); - fInputName = inputs; - } - - /** - * Constructor. - * @param StringBuffer buffer to append codegen - */ - public MethodFileGenerator (StringBuffer buffer,String inputs) - { - super(buffer); - fInputName = inputs; - } - - - public void setFileNames(String inputs) - { - fInputName = inputs; - } - - //public static String LOCATOR = "Locator"; - public static String BEAN = "Proxy"; - public static String GET = "get"; - - - //takes in a bean node - public IStatus visit (Object object) - { - Element beanElement = (Element)object; - fbuffer.append("<%@page contentType=\"text/html;charset=UTF-8\"%>"); - fbuffer.append("<HTML>" + StringUtils.NEWLINE + "<HEAD>" + StringUtils.NEWLINE + "<TITLE>Methods</TITLE>" + StringUtils.NEWLINE + "</HEAD>" + StringUtils.NEWLINE + "<BODY>" + StringUtils.NEWLINE + "<H1>Methods</H1>" + StringUtils.NEWLINE + "<UL>" + StringUtils.NEWLINE); - MethodVisitor methodVisitor = new MethodVisitor(); - MethodFileHelpGenerator methodFileHelpGenerator = new MethodFileHelpGenerator(fbuffer,fInputName); - methodVisitor.run(beanElement,methodFileHelpGenerator); - fbuffer = methodFileHelpGenerator.getStringBuffer(); - fbuffer.append("</UL>" + StringUtils.NEWLINE + "</BODY>" + StringUtils.NEWLINE + "</HTML>"); - - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/MethodFileHelpGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/MethodFileHelpGenerator.java deleted file mode 100644 index d5d0b7598..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/MethodFileHelpGenerator.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.MethodElement; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a MethodFilegenerator. -* */ -public class MethodFileHelpGenerator extends MethodFileGenerator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - /** - * Constructor. - * - */ - public MethodFileHelpGenerator (StringBuffer buffer,String inputName) - { - super(buffer,inputName); - } - - - //takes in a Method node - public IStatus visit (Object object) - { - Element methodElement = (Element)object; - MethodElement method = (MethodElement)methodElement; - if (method.getMethodOmmission()) return Status.OK_STATUS; - - fbuffer.append("<LI><A HREF=\"" + fInputName + "?method=" + method.getNumberID()); - fbuffer.append("\" TARGET=\"inputs\"> " + method.getDisplayName()); - fbuffer.append("</A></LI>" + StringUtils.NEWLINE); - - return Status.OK_STATUS; - } - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileAttributeGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileAttributeGenerator.java deleted file mode 100644 index d1866f4e1..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileAttributeGenerator.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060612 145433 gilberta@ca.ibm.com - Gilbert Andrews - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import java.util.Vector; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.TypeVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.AttributeElementType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.DataType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; -import org.eclipse.wst.ws.internal.datamodel.BasicElement; - -/** -* Objects of this class represent a ResultFileAttributeGenerator. -* */ -public class ResultFileAttributeGenerator extends ResultFileHelp2Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private Vector fSetterVector; - - /** - * Constructor. - * @param buffer StringBuffer object that this code generator writes to - */ - public ResultFileAttributeGenerator (StringBuffer buffer) - { - super(buffer); - - } - - /** - * Setter vector - */ - public Vector getSetterVector() - { - return fSetterVector; - } - - - /** - * Visit Method generates code for this Visitor - * @param Parameter parameter code will be generated - */ - public IStatus visit (Object object) - { - AttributeElementType attributeElementType = (AttributeElementType)object; - if(attributeElementType.getSetterMethod() == null) return Status.OK_STATUS; - BasicElement element = (BasicElement)object; - if(attributeElementType.getTypeElement().isSimple() || TypeFactory.recognizedBean(attributeElementType.getTypeElement().getName())){ - //start the codegen - //ask the datatype for its request line, it may need mark up or not. - //ie For the simple types we need the mark up - //for the dom element we cant use it. - DataType dataType = TypeFactory.createType(attributeElementType.getTypeElement().getName(),element.getMUID()); - setTypeOwnerId(idName(element.getName())); - fbuffer.append(dataType.getRequestCode(element.getMUID(),getTypeOwnerId())); - - } - - TypeVisitor typeVisitor = new TypeVisitor(); - ResultFileTypeGenerator resultFileTypeGenerator = new ResultFileTypeGenerator(fbuffer); - resultFileTypeGenerator.setNumberFactory(getNumberFactory()); - resultFileTypeGenerator.setTypeOwnerId(getTypeOwnerId()); - - typeVisitor.run(attributeElementType,resultFileTypeGenerator); - setNumberFactory(resultFileTypeGenerator.getNumberFactory()); - Vector setterInputs = resultFileTypeGenerator.getResidentVector(); - putResidentVector(attributeElementType.getSetterSignature((String)setterInputs.firstElement())); - - return Status.OK_STATUS; - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileGenerator.java deleted file mode 100644 index 0427721f0..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileGenerator.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060523 142296 gilberta@ca.ibm.com - Gilbert Andrews - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.MethodVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.BeanElement; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a MethodFilegenerator. -* */ -public class ResultFileGenerator extends Generator -{ - public static String TRIPLE_TAB = Generator.DOUBLE_TAB + Generator.TAB; - public static String QUAD_TAB = Generator.DOUBLE_TAB + Generator.DOUBLE_TAB; - - private String setEndpointMethod; - - /** - * Constructor. - * - */ - public ResultFileGenerator () - { - super(); - } - - /** - * Constructor. - * - */ - public ResultFileGenerator (StringBuffer buffer) - { - super(buffer); - } - - //takes in a bean node - public IStatus visit (Object object) - { - Element beanElement = (Element)object; - BeanElement bean = (BeanElement)beanElement; - fbuffer.append("<%@page contentType=\"text/html;charset=UTF-8\"%>"+ StringUtils.NEWLINE); - fbuffer.append("<% request.setCharacterEncoding(\"UTF-8\"); %>"+ StringUtils.NEWLINE); - fbuffer.append("<HTML>" + StringUtils.NEWLINE); - fbuffer.append("<HEAD>" + StringUtils.NEWLINE); - fbuffer.append("<TITLE>Result</TITLE>" + StringUtils.NEWLINE); - fbuffer.append("</HEAD>" + StringUtils.NEWLINE); - fbuffer.append("<BODY>" + StringUtils.NEWLINE); - fbuffer.append("<H1>Result</H1>" + StringUtils.NEWLINE + StringUtils.NEWLINE); - - fbuffer.append("<jsp:useBean id=\""+ getSessionBeanId() + "\" scope=\"session\" class=\""); - fbuffer.append(bean.getName() + "\" />" + StringUtils.NEWLINE); - if (setEndpointMethod != null && setEndpointMethod.length() > 0) - { - fbuffer.append("<%"); - fbuffer.append(StringUtils.NEWLINE); - fbuffer.append("if (request.getParameter(\"endpoint\") != null && request.getParameter(\"endpoint\").length() > 0)"); - fbuffer.append(StringUtils.NEWLINE); - fbuffer.append(getSessionBeanId()); - fbuffer.append("."); - int index = setEndpointMethod.indexOf('?'); - if (index != -1) - { - fbuffer.append(setEndpointMethod.substring(0, index)); - fbuffer.append("(new "); - fbuffer.append(setEndpointMethod.substring(index+1, setEndpointMethod.length())); - fbuffer.append("(request.getParameter(\"endpoint\")));"); - } - else - { - fbuffer.append(setEndpointMethod); - fbuffer.append("(request.getParameter(\"endpoint\"));"); - } - fbuffer.append(StringUtils.NEWLINE); - fbuffer.append("%>"); - fbuffer.append(StringUtils.NEWLINE); - } - fbuffer.append(StringUtils.NEWLINE); - - //carry on with regular gorp - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("String method = request.getParameter(\"method\");" + StringUtils.NEWLINE); - fbuffer.append("int methodID = 0;" + StringUtils.NEWLINE); - fbuffer.append("if (method == null) methodID = -1;" + StringUtils.NEWLINE + "" + StringUtils.NEWLINE); - fbuffer.append("if(methodID != -1) methodID = Integer.parseInt(method);" + StringUtils.NEWLINE); - fbuffer.append("boolean gotMethod = false;" + StringUtils.NEWLINE + StringUtils.NEWLINE); - - fbuffer.append("try {" + StringUtils.NEWLINE); - fbuffer.append("switch (methodID){ " + StringUtils.NEWLINE); - - // go to the next generator - MethodVisitor methodVisitor = new MethodVisitor(); - ResultFileHelp1Generator resultFileHelp1Generator = new ResultFileHelp1Generator(fbuffer); - resultFileHelp1Generator.setNumberFactory(getNumberFactory()); - resultFileHelp1Generator.setClientFolderPath(getClientFolderPath()); - methodVisitor.run(beanElement,resultFileHelp1Generator); - setNumberFactory(resultFileHelp1Generator.getNumberFactory()); - - fbuffer = resultFileHelp1Generator.getStringBuffer(); - - fbuffer.append("}" + StringUtils.NEWLINE); - fbuffer.append("} catch (Exception e) { " + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("exception: <%= e %>" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("return;" + StringUtils.NEWLINE); - fbuffer.append("}" + StringUtils.NEWLINE); - fbuffer.append("if(!gotMethod){" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("result: N/A" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("}" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("</BODY>" + StringUtils.NEWLINE); - fbuffer.append("</HTML>"); - - return Status.OK_STATUS; - } - - /** - * @param setEndpointMethod The setEndpointMethod to set. - */ - public void setSetEndpointMethod(String setEndpointMethod) - { - this.setEndpointMethod = setEndpointMethod; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileHelp1Generator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileHelp1Generator.java deleted file mode 100644 index a1677f788..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileHelp1Generator.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import java.util.Enumeration; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.ParameterVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.ReturnParameterVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.DataType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.MethodElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; -import org.eclipse.wst.ws.internal.datamodel.Element; - - -/** -* Objects of this class represent a ResultFilegenerator. -* */ -public class ResultFileHelp1Generator extends ResultFileGenerator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - public static final int INITIAL_STATE = 1; - public static final int FINAL_STATE = 2; - public static final String MTEMP = "mtemp"; - public static String BEAN = "Proxy"; - - /** - * Constructor. - * @param buffer StringBuffer object that this code generator writes to - */ - public ResultFileHelp1Generator (StringBuffer buffer) - { - super(buffer); - } - - /** - * Visit Method generates code for this Visitor - * @param method method code will be generated for - */ - public IStatus visit (Object object) - { - Element methodElement = (Element)object; - - - MethodElement method = (MethodElement)methodElement; - if (method.getMethodOmmission()) return Status.OK_STATUS; - - fbuffer.append("case " + method.getNumberID()+ ":" + StringUtils.NEWLINE); - visitHelper(method); - - fbuffer.append("break;" + StringUtils.NEWLINE); - - return Status.OK_STATUS; - } - /** - * Helps out the visitor - * @param method method code will be generated for - */ - public void visitHelper (Element methodElement) - { - - fbuffer.append(Generator.DOUBLE_TAB + "gotMethod = true;" + StringUtils.NEWLINE); - - MethodElement method = (MethodElement)methodElement; - // go to the next generator - ResultFileHelp2Generator resultFileHelp2Generator = new ResultFileHelp2Generator(fbuffer); - resultFileHelp2Generator.setNumberFactory(getNumberFactory()); - ParameterVisitor parameterVisitor = new ParameterVisitor(); - parameterVisitor.run(methodElement,resultFileHelp2Generator); - fbuffer = resultFileHelp2Generator.getStringBuffer(); - setNumberFactory(resultFileHelp2Generator.getNumberFactory()); - // we must now grab the state data from the resident vector - setResidentVector(resultFileHelp2Generator.getResidentVector()); - - - //there is no return type if void occurs - - - if (method.getReturnParameterElement().getTypeElement().getName().equals("void")) - fbuffer.append(Generator.DOUBLE_TAB + getSessionBeanId() + "." +method.getName() + "("); - - else{ - fbuffer.append(Generator.DOUBLE_TAB + method.getReturnParameterElement().getTypeElement().getName() + Generator.SPACE + method.getMUID() + MTEMP + Generator.SPACE); - fbuffer.append("=" + Generator.SPACE + getSessionBeanId() + "." + method.getName() + "("); - } - - Enumeration e = fResidentVector.elements(); - while (e.hasMoreElements()){ - fbuffer.append((String)e.nextElement()); - if (e.hasMoreElements()) - fbuffer.append(","); - } - fbuffer.append(");" + StringUtils.NEWLINE); - if (!method.getReturnParameterElement().getTypeElement().getName().equals("void") && !method.getReturnParameterElement().getTypeElement().isPrimitive()){ - //in case our result is null - fbuffer.append("if(" + method.getMUID() + "mtemp == null){" + StringUtils.NEWLINE); - fbuffer.append("%>" + StringUtils.NEWLINE); - fbuffer.append("<%=" + method.getMUID() + "mtemp %>" + StringUtils.NEWLINE); - fbuffer.append("<%" + StringUtils.NEWLINE); - fbuffer.append("}else{" + StringUtils.NEWLINE); - } - - //now lets display the return bean - // if it is simple we dont need to use the generator - - if (!method.getReturnParameterElement().getTypeElement().getName().equals("void")){ - if (method.getReturnParameterElement().getTypeElement().isSimple() - || TypeFactory.recognizedBean(method.getReturnParameterElement().getTypeElement().getName()) - || TypeFactory.isStateLessBean(method.getReturnParameterElement().getTypeElement().getTypeName()) - || TypeFactory.isRecognizedReturnType(method.getReturnParameterElement().getTypeElement().getTypeName())){ - DataType dataType = TypeFactory.createType(method.getReturnParameterElement().getTypeElement().getTypeName(),method.getReturnParameterElement().getMUID()); - fbuffer.append(dataType.TypeConversion(method.getMUID() + MTEMP)); - } - else{ - fbuffer.append("%>" + StringUtils.NEWLINE); - InputFileHelp2Generator inputFileHelp2Generator = new InputFileHelp2Generator(fbuffer); - inputFileHelp2Generator.setInstanceName(method.getMUID() + MTEMP); - inputFileHelp2Generator.setReturnParam(true); - ReturnParameterVisitor returnParameterVisitor = new ReturnParameterVisitor(); - returnParameterVisitor.run(method,inputFileHelp2Generator); - fbuffer = inputFileHelp2Generator.getStringBuffer(); - fbuffer.append("<%" + StringUtils.NEWLINE); - - } - } - - if (!method.getReturnParameterElement().getTypeElement().getName().equals("void") && !method.getReturnParameterElement().getTypeElement().isPrimitive()) fbuffer.append("}" + StringUtils.NEWLINE); - - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileHelp2Generator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileHelp2Generator.java deleted file mode 100644 index b12280718..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileHelp2Generator.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.TypeVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.DataType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.ParameterElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; - -/** -* Objects of this class represent a ResultFileHelp2generator. -* */ -public class ResultFileHelp2Generator extends Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private String fTypeOwnerId; - - - /** - * Constructor. - * @param buffer StringBuffer object that this code generator writes to - */ - public ResultFileHelp2Generator (StringBuffer buffer) - { - super(buffer); - - } - - /** - * Visit Method generates code for this Visitor - * @param Parameter parameter code will be generated - */ - public IStatus visit (Object object) - { - - - ParameterElement parameterElement = (ParameterElement)object; - parameterElement.getTypeElement(); - if(parameterElement.getTypeElement().isSimple() || TypeFactory.recognizedBean(parameterElement.getTypeElement().getName())){ - //start the codegen - //ask the datatype for its request line, it may need mark up or not. - //ie For the simple types we need the mark up - //for the dom element we cant use it. - DataType dataType = TypeFactory.createType(parameterElement.getTypeElement().getName(),parameterElement.getMUID()); - setTypeOwnerId(idName(parameterElement.getName())); - fbuffer.append(dataType.getRequestCode(parameterElement.getMUID(),getTypeOwnerId())); - } - - //visit the type generator - ResultFileTypeGenerator resultFileTypeGenerator = new ResultFileTypeGenerator(fbuffer); - resultFileTypeGenerator.setNumberFactory(getNumberFactory()); - resultFileTypeGenerator.setTypeOwnerId(getTypeOwnerId()); - TypeVisitor TypeVisitor = new TypeVisitor(); - TypeVisitor.run(parameterElement,resultFileTypeGenerator); - fbuffer = resultFileTypeGenerator.getStringBuffer(); - setNumberFactory(resultFileTypeGenerator.getNumberFactory()); - String name = (String)resultFileTypeGenerator.getResidentVector().firstElement(); - putResidentVector(name); - - return Status.OK_STATUS; - } - - - public String getTypeOwnerId() - { - if (fTypeOwnerId == null) fTypeOwnerId = ""; - return fTypeOwnerId; - } - - public void setTypeOwnerId(String name) - { - fTypeOwnerId = name; - } - - public String idName(String name) - { - - String uniqueNum = String.valueOf(getUniqueNumber()); - String newName = name.replace('.','1') + "_" +uniqueNum + "id"; - return newName; - } - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileTypeGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileTypeGenerator.java deleted file mode 100644 index d60d89799..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/ResultFileTypeGenerator.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070410 180952 makandre@ca.ibm.com - Andrew Mak, Sample JSP generator chokes on interfaces and abstract classes - * 20071110 209087 gilberta@ca.ibm.com - Gilbert Andrews - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import java.util.Enumeration; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.AttributeVisitor; -import org.eclipse.jst.ws.internal.consumption.codegen.bean.FieldVisitor; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.DataType; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement; -import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory; -import org.eclipse.wst.ws.internal.datamodel.Element; - -/** -* Objects of this class represent a ResultFileHelp2generator. -* */ -public class ResultFileTypeGenerator extends ResultFileHelp2Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - - public String fTypeIdName; - - /** - * Constructor. - * @param buffer StringBuffer object that this code generator writes to - */ - public ResultFileTypeGenerator (StringBuffer buffer) - { - super(buffer); - } - - /** - * Visit Method generates code for this Visitor - * @param Parameter parameter code will be generated - */ - public IStatus visit (Object object) - { - Element typeElement = (Element)object; - TypeElement type = (TypeElement)typeElement; - // right now we only have simple to worry about - if(type.isSimple() || TypeFactory.recognizedBean(type.getName())){ - // create the type that represents the simple type name - DataType dataType = TypeFactory.createType(type.getName(),type.getOwningElement().getMUID()); - - String nodeName = getTypeOwnerId()+ "Temp"; - if(!type.isPrimitive()){ - - fbuffer.append(Generator.DOUBLE_TAB + Generator.TAB + type.getName() + " " + nodeName + " = null;" + StringUtils.NEWLINE); - fbuffer.append(Generator.DOUBLE_TAB + "if(!" + getTypeOwnerId() + ".equals(\"\")){" + StringUtils.NEWLINE); - fbuffer.append(dataType.stringConversion("",nodeName,getTypeOwnerId())); - fbuffer.append(Generator.DOUBLE_TAB + "}" + StringUtils.NEWLINE); - } - else - fbuffer.append(dataType.stringConversion(type.getName(),nodeName,getTypeOwnerId())); - - putResidentVector(nodeName); - } - - else { - //must be complex - String typeName = typeElement.getName(); - fTypeIdName = idName(typeName); - - if (!Boolean.TRUE.equals(typeElement.getPropertyAsObject(TypeElement.NON_INSTANTIABLE))) { - - AttributeVisitor attributeVisitor = new AttributeVisitor(); - ResultFileAttributeGenerator resultFileAttributeGenerator = new ResultFileAttributeGenerator(fbuffer); - resultFileAttributeGenerator.setNumberFactory(getNumberFactory()); - attributeVisitor.run(typeElement,resultFileAttributeGenerator); - setNumberFactory(resultFileAttributeGenerator.getNumberFactory()); - fbuffer = resultFileAttributeGenerator.getStringBuffer(); - - FieldVisitor fieldVisitor = new FieldVisitor(); - ResultFileAttributeGenerator resultFileAttributeGenerator2 = new ResultFileAttributeGenerator(fbuffer); - resultFileAttributeGenerator2.setNumberFactory(getNumberFactory()); - fieldVisitor.run(typeElement,resultFileAttributeGenerator2); - setNumberFactory(resultFileAttributeGenerator2.getNumberFactory()); - fbuffer = resultFileAttributeGenerator2.getStringBuffer(); - - - fbuffer.append(Generator.DOUBLE_TAB + "%>" + StringUtils.NEWLINE); - fbuffer.append(Generator.DOUBLE_TAB + "<jsp:useBean id=\"" + fTypeIdName + "\" scope=\"session\" class=\"" + typeName + "\" />" + StringUtils.NEWLINE); - fbuffer.append(Generator.DOUBLE_TAB + "<%" + StringUtils.NEWLINE); - - Enumeration e = resultFileAttributeGenerator.getResidentVector().elements(); - while(e.hasMoreElements()){ - fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e.nextElement() + StringUtils.NEWLINE); - } - - Enumeration e2 = resultFileAttributeGenerator2.getResidentVector().elements(); - while(e2.hasMoreElements()){ - fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e2.nextElement() + StringUtils.NEWLINE); - } - } - else - fbuffer.append(Generator.DOUBLE_TAB + typeName + " " + fTypeIdName + " = null;"+ StringUtils.NEWLINE); - - putResidentVector(fTypeIdName); - //end of changes - - } - - return Status.OK_STATUS; - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/TestClientFileGenerator.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/TestClientFileGenerator.java deleted file mode 100644 index 04714bbdd..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/codegen/TestClientFileGenerator.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.codegen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.common.StringUtils; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; - - -/** -* Objects of this class represent a TestClientFilegenerator. -* */ -public class TestClientFileGenerator extends Generator -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - public String fMethodName; - public String fInputName; - public String fResultName; - - /** - * Constructor. - * - */ - public TestClientFileGenerator (String inputs, String methods, String results) - { - super(); - fInputName = inputs; - fMethodName = methods; - fResultName = results; - } - - public void setFileNames(String inputs, String methods, String results) - { - fInputName = inputs; - fMethodName = methods; - fResultName = results; - } - - //takes in a bean node - public IStatus visit (Object object) - { - fbuffer.append("<%@page contentType=\"text/html;charset=UTF-8\"%>"); - fbuffer.append("<HTML>" + StringUtils.NEWLINE); - fbuffer.append("<HEAD>" + StringUtils.NEWLINE); - fbuffer.append("<TITLE>Web Services Test Client</TITLE>" + StringUtils.NEWLINE); - fbuffer.append("</HEAD>" + StringUtils.NEWLINE + ""); - fbuffer.append("<FRAMESET COLS=\"220,*\">" + StringUtils.NEWLINE); - fbuffer.append("<FRAME SRC=\""+ fMethodName + "\" NAME=\"methods\" MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SCROLLING=\"yes\" FRAMEBORDER=\"1\">" + StringUtils.NEWLINE); - fbuffer.append("<FRAMESET ROWS=\"80%,20%\">" + StringUtils.NEWLINE); - fbuffer.append("<FRAME SRC=\""+ fInputName + "\" NAME=\"inputs\" MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SCROLLING=\"yes\" FRAMEBORDER=\"1\">" + StringUtils.NEWLINE); - fbuffer.append("<%").append(StringUtils.NEWLINE); - fbuffer.append("StringBuffer resultJSP = new StringBuffer(\"").append(fResultName).append("\");").append(StringUtils.NEWLINE); - fbuffer.append("resultJSP.append(\"?\");").append(StringUtils.NEWLINE); - fbuffer.append("java.util.Enumeration resultEnum = request.getParameterNames();"); - fbuffer.append("while (resultEnum.hasMoreElements()) {").append(StringUtils.NEWLINE); - fbuffer.append("Object resultObj = resultEnum.nextElement();").append(StringUtils.NEWLINE); - fbuffer.append("resultJSP.append(resultObj.toString()).append(\"=\").append(request.getParameter(resultObj.toString())).append(\"&\");").append(StringUtils.NEWLINE); - fbuffer.append("}").append(StringUtils.NEWLINE); - fbuffer.append("%>").append(StringUtils.NEWLINE); - fbuffer.append("<FRAME SRC=\"<%=resultJSP.toString()%>\" NAME=\"result\" MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SCROLLING=\"yes\" FRAMEBORDER=\"1\">" + StringUtils.NEWLINE); - fbuffer.append("</FRAMESET>" + StringUtils.NEWLINE); - - - fbuffer.append("<NOFRAMES>" + StringUtils.NEWLINE); - fbuffer.append("<BODY>" + StringUtils.NEWLINE); - fbuffer.append("The Web Services Test Client requires a browser that supports frames." + StringUtils.NEWLINE); - fbuffer.append("</BODY>" + StringUtils.NEWLINE); - fbuffer.append("</NOFRAMES>" + StringUtils.NEWLINE); - fbuffer.append("</FRAMESET>" + StringUtils.NEWLINE); - fbuffer.append("</HTML>"); - - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/command/GeneratePageCommand.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/command/GeneratePageCommand.java deleted file mode 100644 index d1d7f87c5..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/command/GeneratePageCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.command; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.consumption.codegen.Generator; -import org.eclipse.wst.command.internal.env.common.FileResourceUtils; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.command.internal.env.core.context.ResourceContext; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.ws.internal.datamodel.Element; -import org.eclipse.wst.ws.internal.datamodel.Model; - - -/** - * MofToBeanModelCommand - * Creation date: (4/10/2001 12:41:48 PM) - * @author: Gilbert Andrews - */ -public class GeneratePageCommand extends AbstractDataModelOperation -{ - -private Model model_; -private Generator fGenerator; -private IFile fIFile; -private ResourceContext resourceContext_; -private StringBuffer fStringBuffer; - -/** - * Build constructor comment. - */ -public GeneratePageCommand() -{ -} - -/** -* Constructor -* This command will generate code from a Model -* @param model The model to be traversed -* @param generator The code generator to be used -* @param resource the resource to place the finished product -*/ -public GeneratePageCommand(ResourceContext context, Model model, Generator generator, IFile file) -{ - model_ = model; - fGenerator = generator; - fIFile = file; - resourceContext_ = context; -} - -public Model getJavaDataModel() -{ - return model_; -} - -/** - * - */ -public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable ) -{ - IEnvironment env = getEnvironment(); - - IStatus status = Status.OK_STATUS; - try { - fGenerator.visit(model_.getRootElement()); - fStringBuffer = fGenerator.getStringBuffer(); - String tempString = fStringBuffer.toString(); - OutputStream fileResource = FileResourceUtils.newFileOutputStream(resourceContext_, fIFile.getFullPath(), monitor, env.getStatusHandler()); - //PrintStream ps = new PrintStream(fileResource); - //ps.print(tempString); - OutputStreamWriter osw = new OutputStreamWriter(fileResource,"UTF-8"); - osw.write(tempString,0,fStringBuffer.length()); - osw.close(); - fileResource.close(); - return status; - } catch (IOException ioexc) { - status = StatusUtils.errorStatus( ioexc ); - return status; - } -} - -public void setRootElement(Element rootElement) -{ -} - -} - diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/command/JavaToModelCommand.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/command/JavaToModelCommand.java deleted file mode 100644 index b40810432..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/command/JavaToModelCommand.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.command; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitoractions.JavaMofBeanVisitorAction; -import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofBeanVisitor; -import org.eclipse.jst.ws.internal.consumption.command.common.JavaMofReflectionCommand; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.command.internal.env.core.selection.BooleanSelection; -import org.eclipse.wst.common.environment.Choice; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.ws.internal.datamodel.Element; -import org.eclipse.wst.ws.internal.datamodel.Model; - -/** -* This is the base class for commands that need to report progress -* and status during and after their execution. This class extends -* {@link org.eclipse.emf.common.command.AbstractCommand AbstractCommand} - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - -* with methods to {@link #setProgressMonitor set} -* and {@link #getProgressMonitor get} a progress monitor, -* and to get a status object {@link #getReadyStatus before} -* or {@link #getResultStatus after} execution. -* <p> -* Note that the responsibility of providing an -* {@link org.eclipse.core.runtime.IProgressMonitor IProgressMonitor} -* rests with frameworks that construct or run ProgressCommand objects, -* whereas the responsibility of providing an -* {@link org.eclipse.core.runtime.IStatus IStatus} -* object lies with the subclasses of ProgressCommand. -* Subclasses must follow the rules described for -* {@link org.eclipse.emf.common.command.AbstractCommand AbstractCommand}. -*/ -public class JavaToModelCommand extends AbstractDataModelOperation -{ - - private String clientProject; - private BooleanSelection[] methods; - private String proxyBean; - private JavaClass javaClass; - private Model model; - private Element parentElement; - - public JavaToModelCommand () - { - } - - - private IStatus createJavaReflection(IEnvironment env, IProgressMonitor monitor ) - { - IStatus status = Status.OK_STATUS; - JavaMofReflectionCommand javaMofReflectionCommand = new JavaMofReflectionCommand(); - javaMofReflectionCommand.setClientProject(clientProject); - javaMofReflectionCommand.setProxyBean(proxyBean); - javaMofReflectionCommand.setEnvironment( env ); - //javaMofReflectionCommand.setStatusMonitor(getStatusMonitor()); - status = javaMofReflectionCommand.execute( monitor, null); - javaClass = (JavaClass)javaMofReflectionCommand.getJavaClass(); - return status; - } - - /** - * The Model that was created from this javamof - * @return Model The data model that was created - **/ - public Model getJavaDataModel() - { - return model; - } - - /** - * Build the datamodel from the mof - */ - public IStatus buildModelFromMof (IEnvironment env) throws CoreException - { - - Choice OKChoice = new Choice('O', ConsumptionMessages.LABEL_OK, ConsumptionMessages.DESCRIPTION_OK); - Choice CancelChoice = new Choice('C', ConsumptionMessages.LABEL_CANCEL, ConsumptionMessages.DESCRIPTION_CANCEL); - - // we could have one of three cases: - //1. The model is null meaning we want and the parent element is null, meaning we want to - // create a brand new model and make this bean its root - //2. The model is null but the parentElement is not, meaning we want to add the Bean to the - // given parent element - //3. The model is not null however the parentElement is, meaning we want to add this Bean to - // This model but dont attach it to anything - IStatus status = Status.OK_STATUS; - - if(model == null && parentElement == null){ - JavaMofBeanVisitorAction beanVisitorAction = new JavaMofBeanVisitorAction(clientProject,methods, env); - //beanVisitorAction.setStatusMonitor(getStatusMonitor()); - JavaMofBeanVisitor beanVisitor = new JavaMofBeanVisitor(); - status = beanVisitor.run(javaClass,beanVisitorAction); - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - model = beanVisitorAction.getModel(); - - } - else if (model == null && parentElement != null){ - JavaMofBeanVisitorAction beanVisitorAction = new JavaMofBeanVisitorAction(parentElement,clientProject, env); - //beanVisitorAction.setStatusMonitor(getStatusMonitor()); - JavaMofBeanVisitor beanVisitor = new JavaMofBeanVisitor(); - status = beanVisitor.run(javaClass,beanVisitorAction); - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - model = beanVisitorAction.getModel(); - } - else { - JavaMofBeanVisitorAction beanVisitorAction = new JavaMofBeanVisitorAction(model,clientProject, env); - //beanVisitorAction.setStatusMonitor(getStatusMonitor()); - JavaMofBeanVisitor beanVisitor = new JavaMofBeanVisitor(); - status = beanVisitor.run(javaClass,beanVisitorAction); - // - int severity = status.getSeverity(); - if (severity==Status.ERROR) - return status; - - if (severity==Status.WARNING) - { - Choice result = env.getStatusHandler().report(status, new Choice[]{OKChoice, CancelChoice}); - if (result.getLabel().equals(CancelChoice.getLabel())) - { - //return an error status since the user canceled - return StatusUtils.errorStatus( ConsumptionMessages.MSG_ERROR_SAMPLE_CREATION_CANCELED ); - } - - } - // - model = beanVisitorAction.getModel(); - } - - return status; - } - - /** - * Get the java model from the resource then - * build the model from the mof - */ - public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable ) - { - IEnvironment env = getEnvironment(); - IStatus status = Status.OK_STATUS; - if(clientProject == null) return status; - - status = createJavaReflection(env, monitor); - if (status.getSeverity()==Status.ERROR) return status; - try{ - status = buildModelFromMof(env); - return status; - }catch(CoreException exc){ - IStatus embeddedStatus = exc.getStatus(); - status = embeddedStatus; - return status; - } - - } - - public void setMethods(BooleanSelection[] methods) - { - this.methods = methods; - } - - public void setClientProject(String clientProject) - { - this.clientProject = clientProject; - } - - public void setParentElement(Element parentElement) - { - this.parentElement = parentElement; - } - - public void setProxyBean(String proxyBean) - { - this.proxyBean = proxyBean; - } - - } - diff --git a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/common/SamplePropertyDescriptor.java b/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/common/SamplePropertyDescriptor.java deleted file mode 100644 index 74f4b0115..000000000 --- a/bundles/org.eclipse.jst.ws.consumption/src/org/eclipse/jst/ws/internal/consumption/sampleapp/common/SamplePropertyDescriptor.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.sampleapp.common; - -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.Method; - - -/** -* Objects of this class represent a PropertyDescriptor. -* */ -public class SamplePropertyDescriptor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - - private Method fReadMethod; - private Method fWriteMethod; - private String fPropertyName; - private JavaHelpers fPropertyType; - private boolean fStatic; - - /* - * Constructor - **/ - public SamplePropertyDescriptor(String name) - { - fPropertyName = name; - } - - /* - * set the ReadMethod - */ - public void setReadMethod(Method readMethod) - { - fReadMethod = readMethod; - } - - /* - * get the ReadMethod - */ - public Method getReadMethod() - { - return fReadMethod; - } - - /* - * set the writeMethod - */ - public void setWriteMethod(Method writeMethod) - { - fWriteMethod = writeMethod; - } - - /* - * get the writeMethod - */ - public Method getWriteMethod() - { - return fWriteMethod; - } - - /* - * set the propertyName - */ - public void setName(String name) - { - fPropertyName= name; - } - - /* - * get the propertyName - */ - public String getName() - { - return fPropertyName; - } - - /* - * set the PropertyType - */ - public void setPropertyType(JavaHelpers propertyType) - { - fPropertyType = propertyType; - } - - /* - * get the PropertyType - */ - public JavaHelpers getPropertyType() - { - return fPropertyType; - } - - public boolean isfStatic() - { - return fStatic; - } - - public void setfStatic(boolean fStatic) - { - this.fStatic = fStatic; - } -} |