Skip to content

Commit

Permalink
Fixes #652, Fixes #653
Browse files Browse the repository at this point in the history
  • Loading branch information
aedelmann committed Jul 2, 2017
1 parent a76addb commit d1f5f29
Show file tree
Hide file tree
Showing 22 changed files with 690 additions and 621 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Require-Bundle: org.eclipse.vorto.core,
org.eclipse.xtext.xbase.lib,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib.macro,
org.eclipse.vorto.codegen
org.eclipse.vorto.codegen,
org.apache.commons.lang3
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.vorto.codegen.aws
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ import org.eclipse.vorto.codegen.api.IVortoCodeGenProgressMonitor
import org.eclipse.vorto.codegen.api.IVortoCodeGenerator
import org.eclipse.vorto.codegen.api.InvocationContext
import org.eclipse.vorto.codegen.api.VortoCodeGeneratorException
import org.eclipse.vorto.codegen.aws.templates.alexa.AlexaIndentSchemaTemplate
import org.eclipse.vorto.codegen.aws.templates.alexa.AlexaSkillLambdaTemplate
import org.eclipse.vorto.codegen.aws.templates.alexa.AlexaSlotTypeTemplate
import org.eclipse.vorto.codegen.aws.templates.alexa.AlexaUtterancesTemplate
import org.eclipse.vorto.codegen.aws.templates.shadow.ThingShadowForOperationsTask
import org.eclipse.vorto.codegen.aws.alexa.templates.AlexaIndentSchemaTemplate
import org.eclipse.vorto.codegen.aws.alexa.templates.AlexaSkillLambdaTemplate
import org.eclipse.vorto.codegen.aws.alexa.templates.AlexaSlotTypeTemplate
import org.eclipse.vorto.codegen.aws.alexa.templates.AlexaUtterancesTemplate
import org.eclipse.vorto.codegen.utils.Utils
import org.eclipse.vorto.core.api.model.datatype.Enum
import org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty
Expand All @@ -42,7 +41,7 @@ class AWSGenerator implements IVortoCodeGenerator {
var output = new GenerationResultZip(infomodel,getServiceKey());
var chainedGenerators = new ChainedCodeGeneratorTask<InformationModel>();

chainedGenerators.addTask(new ThingShadowForOperationsTask());
// chainedGenerators.addTask(new ThingShadowForOperationsTask());

// Adds Generators for Speech to Command using Alexa Skill Service.
// That way it is possible to update a thing shadow by various speech command variations defined as mapping rules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*/
package org.eclipse.vorto.codegen.bosch.things.alexa.templates
package org.eclipse.vorto.codegen.aws.alexa.templates

import org.eclipse.vorto.codegen.api.IFileTemplate
import org.eclipse.vorto.core.api.model.datatype.Enum
Expand All @@ -27,7 +27,7 @@ abstract class AbstractAlexaTemplate implements IFileTemplate<InformationModel>
protected static final String STEREOTYPE_ALEXA = "alexa";

override getPath(InformationModel context) {
return "alexa";
return "aws/alexa";
}

protected def boolean isAlexaSupportedParamType(Param param) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*/
package org.eclipse.vorto.codegen.bosch.things.alexa.templates
package org.eclipse.vorto.codegen.aws.alexa.templates

import org.eclipse.vorto.codegen.api.InvocationContext
import org.eclipse.vorto.core.api.model.informationmodel.InformationModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*/
package org.eclipse.vorto.codegen.bosch.things.alexa.templates
package org.eclipse.vorto.codegen.aws.alexa.templates

import org.apache.commons.lang3.StringUtils
import org.eclipse.vorto.codegen.api.InvocationContext
import org.eclipse.vorto.core.api.model.informationmodel.InformationModel

Expand All @@ -31,13 +30,24 @@ class AlexaSkillLambdaTemplate extends AbstractAlexaTemplate {
var reprompt;
var welcomeOutput = "Let's ask the «element.name». What do you want to know?";
«IF context.configurationProperties.getOrDefault("boschcloud","false").equalsIgnoreCase("true"
var thingsApiToken = "INSERT API TOKEN OF BOSCH IOT THINGS HERE";
var thingId = «context.configurationProperties.getOrDefault("thingId","\"INSERT THING ID HERE\"")»;
var username= "INSERT USERNAME HERE";
var password= "INSERT PASSWORD HERE";


var http = require('http');
«ENDIF»
«IF context.configurationProperties.getOrDefault("awsiot","false").equalsIgnoreCase("true"
var config = {
"thingName": "<PUT THING NAME HERE>",
"endpointAddress": "<PUT YOUR ENDPOINT URL HERE>"
}

var AWS = require('aws-sdk');
var iotdata = new AWS.IotData({endpoint: config.endpointAddress});
«ENDIF»

// --------------- Helpers that build all of the responses -----------------------

Expand Down Expand Up @@ -109,6 +119,7 @@ class AlexaSkillLambdaTemplate extends AbstractAlexaTemplate {
console.log("in fetch«fbProperty.name.toFirstUpper»«statusProperty.name.toFirstUpper»");

var sessionAttributes = {};
«IF context.configurationProperties.getOrDefault("boschcloud","false").equalsIgnoreCase("true"
var httpRequest = {
host : "things.apps.bosch-iot-cloud.com",
path: "/api/1/things/"+thingId,
Expand All @@ -129,6 +140,20 @@ class AlexaSkillLambdaTemplate extends AbstractAlexaTemplate {
callback(sessionAttributes, buildSpeechletResponse("«fbProperty.name»", speechOutput, "", true));
});
});
«ENDIF»
«IF context.configurationProperties.getOrDefault("awsiot","false").equalsIgnoreCase("true"
iotdata.getThingShadow({
thingName: config.thingName
},function(err, data) {
if (err) {
callback(err);
} else {
var jsonPayload = JSON.parse(data.payload);
speechOutput = jsonPayload.state.reported["«element.name»"];
callback(sessionAttributes, buildSpeechletResponse("«fbProperty.name»", speechOutput, "", true));
}
});
«ENDIF»
}
«ENDFOR»
«ENDIF»
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*/
package org.eclipse.vorto.codegen.bosch.things.alexa.templates
package org.eclipse.vorto.codegen.aws.alexa.templates

import org.eclipse.vorto.codegen.api.IFileTemplate
import org.eclipse.vorto.core.api.model.datatype.Enum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*/
package org.eclipse.vorto.codegen.bosch.things.alexa.templates
package org.eclipse.vorto.codegen.aws.alexa.templates

import org.eclipse.vorto.codegen.api.InvocationContext
import org.eclipse.vorto.core.api.model.datatype.Property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 Bosch Software Innovations GmbH 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 v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* The Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*******************************************************************************/
package org.eclipse.vorto.codegen.aws.templates.alexa

import org.eclipse.vorto.codegen.api.IFileTemplate
import org.eclipse.vorto.core.api.model.datatype.Enum
import org.eclipse.vorto.core.api.model.datatype.PrimitiveType
import org.eclipse.vorto.core.api.model.functionblock.Param
import org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam
import org.eclipse.vorto.core.api.model.functionblock.RefParam
import org.eclipse.vorto.core.api.model.informationmodel.InformationModel

/**
* @author Alexander Edelmann (Robert Bosch (SEA) Pte. Ltd)
*/
abstract class AbstractAlexaTemplate implements IFileTemplate<InformationModel> {

protected static final String STEREOTYPE_ALEXA = "alexa";

override getPath(InformationModel context) {
return "aws/alexa";
}

protected def boolean isAlexaSupportedParamType(Param param) {
if (param instanceof PrimitiveParam) {
var primitiveType = (param as PrimitiveParam).type;
if (primitiveType == PrimitiveType.INT ||
primitiveType == PrimitiveType.DATETIME ||
primitiveType == PrimitiveType.LONG) {
return true;
} else {
return false;
}
} else if (param instanceof RefParam && (param as RefParam).type instanceof Enum ) {
return true;
} else {
return false;
}
}

protected def String mapToAlexaSupportedType(Param param) {
if (param instanceof PrimitiveParam) {
var primitiveType = (param as PrimitiveParam).type;
if (primitiveType == PrimitiveType.INT || primitiveType == PrimitiveType.LONG) {
return "AMAZON.NUMBER";
} else if (primitiveType == PrimitiveType.DATETIME) {
return "AMAZON.DATE";
}
} else if(param instanceof RefParam && (param as RefParam).type instanceof Enum) {
return (param as RefParam).type.name
}

return null;
}
}
///*******************************************************************************
// * Copyright (c) 2015, 2016 Bosch Software Innovations GmbH 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 v1.0 which accompany this distribution.
// *
// * The Eclipse Public License is available at
// * http://www.eclipse.org/legal/epl-v10.html
// * The Eclipse Distribution License is available at
// * http://www.eclipse.org/org/documents/edl-v10.php.
// *
// * Contributors:
// * Bosch Software Innovations GmbH - Please refer to git log
// *******************************************************************************/
//package org.eclipse.vorto.codegen.aws.templates.alexa
//
//import org.eclipse.vorto.codegen.api.IFileTemplate
//import org.eclipse.vorto.core.api.model.datatype.Enum
//import org.eclipse.vorto.core.api.model.datatype.PrimitiveType
//import org.eclipse.vorto.core.api.model.functionblock.Param
//import org.eclipse.vorto.core.api.model.functionblock.PrimitiveParam
//import org.eclipse.vorto.core.api.model.functionblock.RefParam
//import org.eclipse.vorto.core.api.model.informationmodel.InformationModel
//
///**
// * @author Alexander Edelmann (Robert Bosch (SEA) Pte. Ltd)
// */
//abstract class AbstractAlexaTemplate implements IFileTemplate<InformationModel> {
//
// protected static final String STEREOTYPE_ALEXA = "alexa";
//
// override getPath(InformationModel context) {
// return "aws/alexa";
// }
//
// protected def boolean isAlexaSupportedParamType(Param param) {
// if (param instanceof PrimitiveParam) {
// var primitiveType = (param as PrimitiveParam).type;
// if (primitiveType == PrimitiveType.INT ||
// primitiveType == PrimitiveType.DATETIME ||
// primitiveType == PrimitiveType.LONG) {
// return true;
// } else {
// return false;
// }
// } else if (param instanceof RefParam && (param as RefParam).type instanceof Enum ) {
// return true;
// } else {
// return false;
// }
// }
//
// protected def String mapToAlexaSupportedType(Param param) {
// if (param instanceof PrimitiveParam) {
// var primitiveType = (param as PrimitiveParam).type;
// if (primitiveType == PrimitiveType.INT || primitiveType == PrimitiveType.LONG) {
// return "AMAZON.NUMBER";
// } else if (primitiveType == PrimitiveType.DATETIME) {
// return "AMAZON.DATE";
// }
// } else if(param instanceof RefParam && (param as RefParam).type instanceof Enum) {
// return (param as RefParam).type.name
// }
//
// return null;
// }
//}
Loading

0 comments on commit d1f5f29

Please sign in to comment.