use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addJoinCause.
public void addJoinCause(Set<Whitespace> ws, String identifier) {
BLangForkJoin forkJoin = (BLangForkJoin) this.forkJoinNodesStack.peek();
forkJoin.joinedBody = (BLangBlockStmt) this.blockNodeStack.pop();
Set<Whitespace> varWS = removeNthFromLast(ws, 3);
forkJoin.addWS(ws);
forkJoin.joinResultVar = (BLangVariable) this.generateBasicVarNode((DiagnosticPos) this.typeNodeStack.peek().getPosition(), varWS, identifier, false);
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endConnectorDef.
public void endConnectorDef(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean publicCon) {
BLangConnector connectorNode = (BLangConnector) this.connectorNodeStack.pop();
connectorNode.pos = pos;
connectorNode.addWS(ws);
connectorNode.setName(this.createIdentifier(identifier));
if (publicCon) {
connectorNode.flagSet.add(Flag.PUBLIC);
}
endEndpointDeclarationScope();
this.compUnit.addTopLevelNode(connectorNode);
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addFieldToObject.
void addFieldToObject(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, int annotCount, boolean isPrivate) {
Set<Whitespace> wsForSemiColon = removeNthFromLast(ws, 0);
BLangObject objectNode = (BLangObject) this.objectStack.peek();
objectNode.addWS(wsForSemiColon);
BLangVariable field = addVar(pos, ws, identifier, exprAvailable, annotCount);
if (!isPrivate) {
field.flagSet.add(Flag.PUBLIC);
}
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class PackageLoader method loadAndDefinePackage.
public BLangPackage loadAndDefinePackage(BLangIdentifier orgName, List<BLangIdentifier> pkgNameComps, BLangIdentifier version) {
// TODO This method is only used by the composer. Can we refactor the composer code?
List<Name> nameComps = pkgNameComps.stream().map(identifier -> names.fromIdNode(identifier)).collect(Collectors.toList());
PackageID pkgID = new PackageID(names.fromIdNode(orgName), nameComps, names.fromIdNode(version));
return loadAndDefinePackage(pkgID);
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project product-iots by wso2.
the class DeviceTypeServiceImpl method getSensorStats.
/**
* Retrieve Sensor data for the given time period.
*
* @param deviceId unique identifier for given device type instance
* @param from starting time
* @param to ending time
* @return response with List<SensorRecord> object which includes sensor data which is requested
*/
@Path("device/stats/{deviceId}")
@GET
@Consumes("application/json")
@Produces("application/json")
public Response getSensorStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to, @QueryParam("sensorType") String sensorType) {
String fromDate = String.valueOf(from);
String toDate = String.valueOf(to);
String query = "meta_deviceId:" + deviceId + " AND meta_deviceType:" + DeviceTypeConstants.DEVICE_TYPE + " AND meta_time : [" + fromDate + " TO " + toDate + "]";
String sensorTableName = null;
if (sensorType.equals(DeviceTypeConstants.SENSOR_TYPE1)) {
sensorTableName = DeviceTypeConstants.SENSOR_TYPE1_EVENT_TABLE;
} else if (sensorType.equals(DeviceTypeConstants.SENSOR_TYPE2)) {
sensorTableName = DeviceTypeConstants.SENSOR_TYPE2_EVENT_TABLE;
}
try {
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(new DeviceIdentifier(deviceId, DeviceTypeConstants.DEVICE_TYPE))) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
if (sensorTableName != null) {
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("meta_time", SortType.ASC);
sortByFields.add(sortByField);
List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();
}
} catch (AnalyticsException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
return Response.status(Response.Status.BAD_REQUEST).build();
}
Aggregations