/******************************************************************************* * Copyright (c) 2012, 2014 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: * * 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 hu.bme.mit.massif.oslc.adaptor.resources; import hu.bme.mit.massif.oslc.adaptor.SimulinkAdaptorConstants; import hu.bme.mit.massif.oslc.adaptor.servlet.ServletListener; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.UriBuilder; import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; 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.OslcResourceShape; import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; import org.eclipse.lyo.oslc4j.core.annotation.OslcValueType; import org.eclipse.lyo.oslc4j.core.model.Link; import org.eclipse.lyo.oslc4j.core.model.Occurs; import org.eclipse.lyo.oslc4j.core.model.ValueType; // Start of user code imports // End of user code @OslcNamespace(SimulinkAdaptorConstants.SIMULINK_NAMSPACE) @OslcName(SimulinkAdaptorConstants.GOTORESOURCE) @OslcResourceShape(title = "GotoResource Resource Shape", describes = SimulinkAdaptorConstants.TYPE_GOTORESOURCE) public class GotoResource extends VirtualBlockResource { private HashSet<Link> fromBlockss = new HashSet<Link>(); private String tagVisibility; private String gotoTag; public GotoResource() throws URISyntaxException { super(); // Start of user code constructor1 // End of user code } public GotoResource(final URI about) throws URISyntaxException { super(about); // Start of user code constructor2 // End of user code } public static URI constructURI(final String serviceProviderId, final String gotoRes) { String basePath = ServletListener.getServicesBase(); Map<String, Object> pathParameters = new HashMap<String, Object>(); pathParameters.put("serviceProviderId", serviceProviderId); pathParameters.put("gotoRes", gotoRes); String instanceURI = "/simu/{serviceProviderId}/gotoResources/{gotoRes}"; final UriBuilder builder = UriBuilder.fromUri(basePath); return builder.path(instanceURI).buildFromMap(pathParameters); } public String toString() { String result = ""; // Start of user code toString_init if (getAbout() == null) { return result; } // End of user code result = getAbout().toString(); // Start of user code toString_finalize // End of user code return result; } public String toHtml() { String result = ""; // Start of user code toHtml_init // End of user code result = "<a href=\"" + getAbout() + "\">" + toString() + "</a>"; // Start of user code toHtml_finalize // End of user code return result; } public void addFromBlocks(final Link fromBlocks) { this.fromBlockss.add(fromBlocks); } @OslcName("fromBlocks") @OslcPropertyDefinition(SimulinkAdaptorConstants.SIMULINK_NAMSPACE + "fromBlocks") @OslcDescription("") @OslcOccurs(Occurs.ZeroOrMany) @OslcValueType(ValueType.Resource) @OslcRange(SimulinkAdaptorConstants.TYPE_FROMRESOURCE) @OslcReadOnly(false) @OslcTitle("fromBlocks") public HashSet<Link> getFromBlockss() { return fromBlockss; } @OslcName("tagVisibility") @OslcPropertyDefinition(SimulinkAdaptorConstants.SIMULINK_NAMSPACE + "tagVisibility") @OslcDescription("") @OslcOccurs(Occurs.ExactlyOne) @OslcValueType(ValueType.String) @OslcReadOnly(false) @OslcTitle("tagVisibility") public String getTagVisibility() { return tagVisibility; } @OslcName("gotoTag") @OslcPropertyDefinition(SimulinkAdaptorConstants.SIMULINK_NAMSPACE + "gotoTag") @OslcDescription("") @OslcOccurs(Occurs.ExactlyOne) @OslcValueType(ValueType.String) @OslcReadOnly(false) @OslcTitle("gotoTag") public String getGotoTag() { return gotoTag; } public void setFromBlockss(final HashSet<Link> fromBlocks) { this.fromBlockss.clear(); if (fromBlocks != null) { this.fromBlockss.addAll(fromBlocks); } } public void setTagVisibility(final String tagVisibility) { this.tagVisibility = tagVisibility; } public void setGotoTag(final String gotoTag) { this.gotoTag = gotoTag; } static public String fromBlockssToHtmlForCreation(final HttpServletRequest httpServletRequest, final String serviceProviderId) { String s = ""; // Start of user code fromBlockssasHtmlForCreation_init // End of user code s = s + "<label for=\"fromBlocks\">fromBlocks: </LABEL>"; // Start of user code fromBlockssasHtmlForCreation_mid // End of user code // Start of user code fromBlockssasHtmlForCreation_finalize // End of user code return s; } static public String tagVisibilityToHtmlForCreation(final HttpServletRequest httpServletRequest, final String serviceProviderId) { String s = ""; // Start of user code tagVisibilityasHtmlForCreation_init // End of user code s = s + "<label for=\"tagVisibility\">tagVisibility: </LABEL>"; // Start of user code tagVisibilityasHtmlForCreation_mid // End of user code s = s + "<input name=\"tagVisibility\" type=\"text\" style=\"width: 400px\" id=\"tagVisibility\" >"; // Start of user code tagVisibilityasHtmlForCreation_finalize // End of user code return s; } static public String gotoTagToHtmlForCreation(final HttpServletRequest httpServletRequest, final String serviceProviderId) { String s = ""; // Start of user code gotoTagasHtmlForCreation_init // End of user code s = s + "<label for=\"gotoTag\">gotoTag: </LABEL>"; // Start of user code gotoTagasHtmlForCreation_mid // End of user code s = s + "<input name=\"gotoTag\" type=\"text\" style=\"width: 400px\" id=\"gotoTag\" >"; // Start of user code gotoTagasHtmlForCreation_finalize // End of user code return s; } public String fromBlockssToHtml() { String s = ""; // Start of user code fromBlocksstoHtml_init // End of user code s = s + "<label for=\"fromBlocks\"><strong>fromBlocks</strong>: </LABEL>"; // Start of user code fromBlocksstoHtml_mid // End of user code try { s = s + "<ul>"; Iterator<Link> itr = fromBlockss.iterator(); while (itr.hasNext()) { s = s + "<li>"; s = s + (new FromResource(itr.next().getValue())).toHtml(); s = s + "</li>"; } s = s + "</ul>"; } catch (Exception e) { e.printStackTrace(); } // Start of user code fromBlocksstoHtml_finalize // End of user code return s; } public String tagVisibilityToHtml() { String s = ""; // Start of user code tagVisibilitytoHtml_init // End of user code s = s + "<label for=\"tagVisibility\"><strong>tagVisibility</strong>: </LABEL>"; // Start of user code tagVisibilitytoHtml_mid // End of user code try { if (tagVisibility == null) { s = s + "<em>null</em>"; } else { s = s + tagVisibility.toString(); } } catch (Exception e) { e.printStackTrace(); } // Start of user code tagVisibilitytoHtml_finalize // End of user code return s; } public String gotoTagToHtml() { String s = ""; // Start of user code gotoTagtoHtml_init // End of user code s = s + "<label for=\"gotoTag\"><strong>gotoTag</strong>: </LABEL>"; // Start of user code gotoTagtoHtml_mid // End of user code try { if (gotoTag == null) { s = s + "<em>null</em>"; } else { s = s + gotoTag.toString(); } } catch (Exception e) { e.printStackTrace(); } // Start of user code gotoTagtoHtml_finalize // End of user code return s; } }