| [comment encoding = UTF-8 /] |
| [comment |
| /******************************************************************************* |
| * Copyright (c) 2012 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 |
| * and Eclipse Distribution License v. 1.0 which accompanies this distribution. |
| * |
| * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| * and the Eclipse Distribution License is available at |
| * http://www.eclipse.org/org/documents/edl-v10.php. |
| * |
| * Contributors: |
| * |
| * Russell Boykin - initial API and implementation |
| * Alberto Giammaria - initial API and implementation |
| * Chris Peters - initial API and implementation |
| * Gianluca Bernardini - initial API and implementation |
| * Sam Padgett - initial API and implementation |
| * Michael Fiedler - adapted for OSLC4J |
| * Jad El-khoury - initial implementation of code generator (https://bugs.eclipse.org/bugs/show_bug.cgi?id=422448) |
| *******************************************************************************/ |
| /] |
| |
| [module generateResourceInterface('http://org.eclipse.lyo/oslc4j/adaptorInterface')] |
| |
| [import org::eclipse::lyo::oslc4j::codegenerator::services::services/] |
| [import org::eclipse::lyo::oslc4j::codegenerator::services::resourceServices/] |
| [import org::eclipse::lyo::oslc4j::codegenerator::services::resourcePropertyServices/] |
| [import org::eclipse::lyo::oslc4j::codegenerator::services::adaptorInterfaceServices/] |
| [import org::eclipse::lyo::oslc4j::codegenerator::services::domainSpecificationServices/] |
| |
| [template public generateResourceInterface(aResource : Resource, contextAdaptorInterface : AdaptorInterface, managingAdaptorInterface: AdaptorInterface)] |
| [file (javaInterfaceFullFileName(aResource, contextAdaptorInterface), false, 'UTF-8')] |
| /******************************************************************************* |
| * Copyright (c) 2012 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 |
| * and Eclipse Distribution License v. 1.0 which accompanies this distribution. |
| * |
| * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| * and the Eclipse Distribution License is available at |
| * http://www.eclipse.org/org/documents/edl-v10.php. |
| * |
| * Contributors: |
| * |
| * Russell Boykin - initial API and implementation |
| * Alberto Giammaria - initial API and implementation |
| * Chris Peters - initial API and implementation |
| * Gianluca Bernardini - initial API and implementation |
| * Sam Padgett - initial API and implementation |
| * Michael Fiedler - adapted for OSLC4J |
| * Jad El-khoury - initial implementation of code generator (https://bugs.eclipse.org/bugs/show_bug.cgi?id=422448) |
| * |
| * This file is generated by org.eclipse.lyo.oslc4j.codegenerator |
| *******************************************************************************/ |
| |
| package [javaInterfacePackageName(aResource, contextAdaptorInterface) /]; |
| |
| import java.net.URI; |
| import java.net.URISyntaxException; |
| import java.util.ArrayList; |
| import java.util.Arrays; |
| import java.util.Date; |
| import java.util.HashMap; |
| import java.util.Map; |
| import java.text.SimpleDateFormat; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.Set; |
| import java.util.TreeSet; |
| import java.util.Iterator; |
| import javax.servlet.http.HttpServletRequest; |
| import java.io.UnsupportedEncodingException; |
| import java.net.URLEncoder; |
| import javax.ws.rs.core.UriBuilder; |
| |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcAllowedValue; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcMemberProperty; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcName; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcRange; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcReadOnly; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcRepresentation; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; |
| import org.eclipse.lyo.oslc4j.core.annotation.OslcValueType; |
| import org.eclipse.lyo.oslc4j.core.model.AbstractResource; |
| import org.eclipse.lyo.oslc4j.core.model.Link; |
| import org.eclipse.lyo.oslc4j.core.model.Occurs; |
| import org.eclipse.lyo.oslc4j.core.model.OslcConstants; |
| import org.eclipse.lyo.oslc4j.core.model.Representation; |
| import org.eclipse.lyo.oslc4j.core.model.ValueType; |
| |
| import [javaInterfaceFullNameForAdaptorConstants(contextAdaptorInterface) /]; |
| [for (aProperty: ResourceProperty | allProperties(aResource)->sortedBy(name))] |
| [if(Sequence{'Resource', 'LocalResource'}->includes(aProperty.valueType.toString())) ] |
| [for (r: Resource | aProperty.range)] |
| import [javaInterfaceFullName(r, contextAdaptorInterface) /]; |
| [/for] |
| [/if] |
| [/for] |
| |
| // [protected ('imports')] |
| // [/protected] |
| |
| @OslcNamespace([javaInterfaceNameForAdaptorConstants(contextAdaptorInterface) /].[domainSpecificationNamespaceConstantName(aResource.definingDomainSpecification()) /]) |
| @OslcName([javaInterfaceNameForAdaptorConstants(contextAdaptorInterface) /].[resourceConstantName(aResource) /]) |
| @OslcResourceShape(title = "[aResource.name /] Resource Shape", describes = [javaInterfaceNameForAdaptorConstants(contextAdaptorInterface) /].[resourceTypeConstantName(aResource) /]) |
| public interface [javaInterfaceName(aResource) /] |
| { |
| |
| [for (aProperty: ResourceProperty | aResource.resourceProperties)] |
| [if (Sequence{'zeroOrMany', 'oneOrMany'}->includes(aProperty.occurs.toString()))] |
| public void add[javaAttributeName(aProperty, aResource).toUpperFirst()/](final [javaAttributeBaseType(aProperty) /] [javaName(aProperty, false)/] ); |
| [/if] |
| [/for] |
| |
| [for (aProperty: ResourceProperty | aResource.resourceProperties)] |
| [if (not (nameAnnotation(aProperty) = ''))] |
| [nameAnnotation(aProperty)/] |
| [/if] |
| [if (not (propertyDefinitionAnnotation(aProperty, aResource, contextAdaptorInterface) = ''))] |
| [propertyDefinitionAnnotation(aProperty, aResource, contextAdaptorInterface)/] |
| [/if] |
| [if (not (descriptionAnnotation(aProperty) = ''))] |
| [descriptionAnnotation(aProperty)/] |
| [/if] |
| [if (not (occursAnnotation(aProperty) = ''))] |
| [occursAnnotation(aProperty)/] |
| [/if] |
| [if (not (valueTypeAnnotation(aProperty) = ''))] |
| [valueTypeAnnotation(aProperty)/] |
| [/if] |
| [if (not (representationAnnotation(aProperty) = ''))] |
| [representationAnnotation(aProperty)/] |
| [/if] |
| [if (not (rangeAnnotation(aProperty, aResource, contextAdaptorInterface)= ''))] |
| [rangeAnnotation(aProperty, aResource, contextAdaptorInterface)/] |
| [/if] |
| [if (not (readOnlyAnnotation(aProperty) = ''))] |
| [readOnlyAnnotation(aProperty)/] |
| [/if] |
| [if (not (titleAnnotation(aProperty)= ''))] |
| [titleAnnotation(aProperty)/] |
| [/if] |
| [if (not (isMemberPropertyAnnotation(aProperty)= ''))] |
| [isMemberPropertyAnnotation(aProperty)/] |
| [/if] |
| [if (not (allowedValueAnnotation(aProperty)= ''))] |
| [allowedValueAnnotation(aProperty)/] |
| [/if] |
| public [javaAttributeTypeDeclaration(aProperty) /] [if (aProperty.valueType.toString() = 'Boolean')]is[else]get[/if][javaAttributeName(aProperty, aResource).toUpperFirst() /](); |
| |
| [/for] |
| |
| [for (aProperty: ResourceProperty | aResource.resourceProperties)] |
| public void set[javaAttributeName(aProperty, aResource).toUpperFirst()/](final [javaAttributeTypeDeclaration(aProperty) /] [javaName(aProperty, false)/] ); |
| [/for] |
| } |
| |
| [/file] |
| [/template] |
| |