use of com.google.cloud.bigquery.connection.v1.Connection in project AGREE by loonwerks.
the class AgreeASTBuilder method getConnectionStatements.
private List<AgreeOverriddenConnection> getConnectionStatements(EList<SpecStatement> specs) {
List<AgreeOverriddenConnection> conns = new ArrayList<>();
for (SpecStatement spec : specs) {
if (spec instanceof ConnectionStatement) {
Expr expr = doSwitch(((ConnectionStatement) spec).getExpr());
Connection conn = (Connection) ((ConnectionStatement) spec).getConn();
AgreeOverriddenConnection agreeConn = new AgreeOverriddenConnection(new AgreeStatement("", expr, spec), conn);
conns.add(agreeConn);
}
}
return conns;
}
use of com.google.cloud.bigquery.connection.v1.Connection in project AGREE by loonwerks.
the class AgreeValidator method checkConnectionStatement.
@Check(CheckType.FAST)
public void checkConnectionStatement(ConnectionStatement conn) {
Classifier container = conn.getContainingClassifier();
if (container instanceof ComponentImplementation) {
NamedElement aadlConn = conn.getConn();
if (aadlConn == null) {
return;
}
if (!(aadlConn instanceof Connection)) {
error(conn, "The connection label in the connection statement is not a connection");
return;
}
TypeDef rhsType = (AgreeTypeSystem.infer(conn.getExpr()));
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, rhsType)) {
error(conn, "The expression for the connection statement is of type '" + nameOfTypeDef(rhsType) + "' but must be of type 'bool'");
}
} else {
error(conn, "Connection statements are allowed only in component implementations.");
}
warning(conn, "Connection statements are deprecated and will be removed in a future version of AGREE.");
}
use of com.google.cloud.bigquery.connection.v1.Connection in project AGREE by loonwerks.
the class AgreeValidator method checkLiftContract.
@Check(CheckType.FAST)
public void checkLiftContract(LiftContractStatement lcst) {
Classifier comp = lcst.getContainingClassifier();
if (comp instanceof ComponentImplementation) {
ComponentType ct = ((ComponentImplementation) comp).getType();
List<AnnexSubclause> agreeAnnexes = AnnexUtil.getAllAnnexSubclauses(ct, AgreePackage.eINSTANCE.getAgreeContractSubclause());
if (agreeAnnexes.size() > 0) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whose type has an AGREE annex.");
}
List<Subcomponent> subcomps = ((ComponentImplementation) comp).getAllSubcomponents();
if (subcomps.size() == 1) {
Subcomponent subcomp = subcomps.get(0);
Classifier subCls = subcomp.getClassifier();
ComponentType subCt = null;
if (subCls instanceof ComponentImplementation) {
subCt = ((ComponentImplementation) subCls).getType();
} else if (subCls instanceof ComponentType) {
subCt = (ComponentType) subCls;
} else {
throw new RuntimeException();
}
{
Set<String> usedParentInPorts = new HashSet<>();
Set<String> usedParentOutPorts = new HashSet<>();
Set<String> usedChildInPorts = new HashSet<>();
Set<String> usedChildOutPorts = new HashSet<>();
EList<Classifier> ctPlusAllExtended = ct.getSelfPlusAllExtended();
EList<Classifier> subCtPlusAllExtended = subCt.getSelfPlusAllExtended();
for (Connection conn : ((ComponentImplementation) comp).getAllConnections()) {
{
NamedElement sourceNe = conn.getSource().getConnectionEnd();
if (subCtPlusAllExtended.contains(sourceNe.getContainingClassifier())) {
if (usedChildOutPorts.contains(sourceNe.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection out of same output " + sourceNe.getQualifiedName() + ".");
}
usedChildOutPorts.add(sourceNe.getName());
}
if (ctPlusAllExtended.contains(sourceNe.getContainingClassifier())) {
if (usedParentInPorts.contains(sourceNe.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection out of same input " + sourceNe.getQualifiedName() + ".");
}
usedParentInPorts.add(sourceNe.getName());
}
}
{
NamedElement destNe = conn.getDestination().getConnectionEnd();
if (subCtPlusAllExtended.contains(destNe.getContainingClassifier())) {
if (usedChildInPorts.contains(destNe.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection into same input " + destNe.getQualifiedName() + ".");
}
usedChildInPorts.add(destNe.getName());
}
if (ctPlusAllExtended.contains(destNe.getContainingClassifier())) {
if (usedParentOutPorts.contains(destNe.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection into same output " + destNe.getQualifiedName() + ".");
}
usedParentOutPorts.add(destNe.getName());
}
}
}
for (Feature feat : comp.getAllFeatures()) {
boolean isIn = false;
if (feat instanceof DataPort) {
isIn = ((DataPort) feat).isIn();
} else if (feat instanceof EventDataPort) {
isIn = ((EventDataPort) feat).isIn();
} else if (feat instanceof EventPort) {
isIn = ((EventPort) feat).isIn();
}
if (isIn) {
if (!usedParentInPorts.contains(feat.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection from input " + feat.getQualifiedName() + ".");
}
} else {
if (!usedParentOutPorts.contains(feat.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection to output " + feat.getQualifiedName() + ".");
}
}
}
for (Feature feat : subCt.getAllFeatures()) {
boolean isIn = false;
if (feat instanceof DataPort) {
isIn = ((DataPort) feat).isIn();
} else if (feat instanceof EventDataPort) {
isIn = ((EventDataPort) feat).isIn();
} else if (feat instanceof EventPort) {
isIn = ((EventPort) feat).isIn();
}
if (isIn) {
if (!usedChildInPorts.contains(feat.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection into " + feat.getQualifiedName() + ".");
}
} else {
if (!usedChildOutPorts.contains(feat.getName())) {
error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection out of " + feat.getQualifiedName() + ".");
}
}
}
}
} else {
error(lcst, "'lift contract;' statement is not allowed in component implementation whithout exactly one subcomponent.");
}
} else {
error(lcst, "'lift contract;' statement is not allowed in component interface.");
}
}
use of com.google.cloud.bigquery.connection.v1.Connection in project spring-cloud-square by spring-projects-experimental.
the class TracingOkHttpInterceptor method parseRouteAddress.
private static void parseRouteAddress(Chain chain, Span span) {
if (span.isNoop()) {
return;
}
Connection connection = chain.connection();
if (connection == null) {
return;
}
InetSocketAddress socketAddress = connection.route().socketAddress();
span.remoteIpAndPort(socketAddress.getHostString(), socketAddress.getPort());
}
use of com.google.cloud.bigquery.connection.v1.Connection in project eladmin by lWoHvYe.
the class ScpClientUtil method putFile.
public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory, String mode) {
Connection conn = new Connection(ip, port);
File file = new File(localFile);
if (file.isDirectory()) {
throw new RuntimeException(localFile + " is not a file");
}
String fileName = file.getName();
try {
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
if (!isAuthenticated) {
System.err.println("authentication failed");
}
var client = conn.createSCPClient();
if ((mode == null) || (mode.length() == 0))
mode = "0600";
var scpOutputStream = client.put(StrUtil.isNotEmpty(remoteFileName) ? remoteFileName : fileName, file.length(), remoteTargetDirectory, mode);
String content = IOUtils.toString(new FileInputStream(file), String.valueOf(StandardCharsets.UTF_8));
scpOutputStream.write(content.getBytes());
scpOutputStream.flush();
scpOutputStream.close();
} catch (IOException ex) {
Logger.getLogger(ScpClientUtil.class.getName()).log(Level.SEVERE, null, ex);
} finally {
conn.close();
}
}
Aggregations