Skip to content

Commit

Permalink
SNSIDA-20: Extract sample, public repository for presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pjazdzyk committed Mar 2, 2024
0 parents commit 7e9e2e5
Show file tree
Hide file tree
Showing 59 changed files with 3,719 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-test-analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Test Analyze
on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize, reopened ]
workflow_dispatch:

jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis.

- name: Set up JDK 17
uses: actions/setup-java@v3.13.0
with:
java-version: 17
distribution: 'zulu'

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Maven - build and test
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=pjazdzyk_indoor-analytics-sample
90 changes: 90 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
##############################
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*

##############################
## Maven
##############################
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
pom.xml.bak
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

##############################
## Gradle
##############################
bin/
build/
.gradle
.gradletasknamecache
gradle-app.setting
!gradle-wrapper.jar

##############################
## IntelliJ
##############################
out/
.idea/
.idea_modules/
*.iml
*.ipr
*.iws

##############################
## Eclipse
##############################
.settings/
tmp/
.metadata
.classpath
.project
*.tmp
*.bak
*.swp
*~.nib
local.properties
.loadpath
.factorypath

##############################
## NetBeans
##############################
nbproject/private/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

##############################
## Visual Studio Code
##############################
.vscode/
.code-workspace

##############################
## OS X
##############################
.DS_Store

#######OTHER##########
*.sample
*.sns
*.sms
/.flattened-pom.xml
/core/.flattened-pom.xml
/api/.flattened-pom.xml
277 changes: 277 additions & 0 deletions README.md

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.synerset</groupId>
<artifactId>indoor-analytics</artifactId>
<version>${project.version}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>indoor-analytics-api</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${open-api.version}</version>
</dependency>
<dependency>
<groupId>com.synerset</groupId>
<artifactId>unitility-validation</artifactId>
</dependency>
<dependency>
<groupId>com.synerset</groupId>
<artifactId>unitility-spring</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.synerset</groupId>
<artifactId>hvac-engine</artifactId>
<version>${hvac-engine.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.synerset.indooranalyticsapi.common;

import io.swagger.v3.oas.annotations.media.Schema;

import java.time.ZonedDateTime;

/**
* Represents an invalid response object returned by the Indoor Analytics service.
* This record encapsulates details such as service name, cause of the error, error message, and timestamp.
*/
public record InvalidResponse(
@Schema(example = "Indoor Analytics")
String serviceName,
@Schema(example = "UnitSystemParseException")
String cause,
@Schema(example = "Unsupported unit symbol: {xyz}. Target class: TemperatureUnits")
String message,
@Schema(example = "2024-02-10T14:39:11.8551038Z")
ZonedDateTime timestamp
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.synerset.indooranalyticsapi.common;

import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
* This interface represents the root of the Swagger Indoor Analytics Rest Service.
* It defines metadata such as title, version, contact information, and external documentation.
*/
@OpenAPIDefinition(
info = @Info(title = "SYNERSET - Indoor Analytics Rest Service", version = "0.0.1-alpha",
contact = @Contact(name = "Author: Piotr Jazdzyk, MSc Eng", url = "https://www.linkedin.com/in/pjazdzyk")),
externalDocs = @ExternalDocumentation(description = "Powered by: HVAC|Engine - HVAC engineering library",
url = "https://github.com/pjazdzyk/hvac-engine"),
tags = {
@Tag(name = "Physical properties service:"),
@Tag(name = "Heating process service:")
})
public interface SwaggerApiRoot {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.synerset.indooranalyticsapi.process.common;

import com.synerset.unitility.unitsystem.flow.MassFlow;
import com.synerset.unitility.unitsystem.flow.VolumetricFlow;
import com.synerset.unitility.unitsystem.humidity.HumidityRatio;
import com.synerset.unitility.unitsystem.humidity.RelativeHumidity;
import com.synerset.unitility.unitsystem.thermodynamic.Pressure;
import com.synerset.unitility.unitsystem.thermodynamic.Temperature;
import com.synerset.unitility.validation.PhysicalRange;
import jakarta.validation.constraints.NotNull;
import org.apache.commons.lang3.ObjectUtils;

public record InletAirFlowRequest(
@PhysicalRange(min = "50_000Pa", max = "5.0MPa")
Pressure inletPressure,
@NotNull
@PhysicalRange(min = "-120oC", max = "165c")
Temperature inletTemperature,
@PhysicalRange(min = "0%", max = "100%")
RelativeHumidity inletRelativeHumidity,
@PhysicalRange(min = "0kg/kg", max = "5.0kg/kg")
HumidityRatio inletHumidityRatio,
@PhysicalRange(min = "0.0m3/h", max = "10.E9m3/h")
VolumetricFlow inletVolFlow,
@PhysicalRange(min = "0.0kg/h", max = "1.2E9kg/h")
MassFlow inletMassFlow
) {
public InletAirFlowRequest {
if (inletPressure == null) {
inletPressure = Pressure.STANDARD_ATMOSPHERE;
}
if (ObjectUtils.allNull(inletRelativeHumidity, inletHumidityRatio)) {
inletHumidityRatio = HumidityRatio.HUM_RATIO_MIN_LIMIT;
}
if (ObjectUtils.allNull(inletMassFlow, inletVolFlow)) {
inletMassFlow = MassFlow.MASS_FLOW_MIN_LIMIT;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.synerset.indooranalyticsapi.process.common;

import com.synerset.unitility.unitsystem.flow.MassFlow;
import com.synerset.unitility.unitsystem.flow.VolumetricFlow;
import com.synerset.unitility.unitsystem.humidity.HumidityRatio;
import com.synerset.unitility.unitsystem.humidity.RelativeHumidity;
import com.synerset.unitility.unitsystem.thermodynamic.Pressure;
import com.synerset.unitility.unitsystem.thermodynamic.SpecificEnthalpy;
import com.synerset.unitility.unitsystem.thermodynamic.Temperature;
import io.swagger.v3.oas.annotations.media.Schema;

public record OutletAirFlowResponse(
@Schema(example = "UNSATURATED")
String outletVapourState,
@Schema(example = "{\"value\": 101325.0,\"unit\": \"Pa\"}")
Pressure outletPressure,
@Schema(example = "{\"value\": 25.0,\"unit\": \"oC\"}")
Temperature outletTemperature,
@Schema(example = "{\"value\": 3.19,\"unit\": \"%\"}")
RelativeHumidity outletRelativeHumidity,
@Schema(example = "{\"value\": 6.217E-4,\"unit\": \"kg/kg\"}")
HumidityRatio outletHumidityRatio,
@Schema(example = "{\"value\": 26.707,\"unit\": \"kJ/kg\"}")
SpecificEnthalpy outletSpecificEnthalpy,
@Schema(example = "{\"value\": 11.60,\"unit\": \"kg/s\"}")
MassFlow outletMassFlow,
@Schema(example = "{\"value\": 11.59,\"unit\": \"kg/s\"}")
MassFlow outletDryAirMassFlow,
@Schema(example = "{\"value\": 35332.806,\"unit\": \"m3/h\"}")
VolumetricFlow outletVolFlow
) {

public OutletAirFlowResponse toImperialUnits() {
return new OutletAirFlowResponse(
outletVapourState,
outletPressure.toPsi(),
outletTemperature.toFahrenheit(),
outletRelativeHumidity,
outletHumidityRatio.toPoundPerPound(),
outletSpecificEnthalpy.toBTUPerPound(),
outletMassFlow.toPoundsPerSecond(),
outletDryAirMassFlow.toPoundsPerSecond(),
outletVolFlow.toCubicFeetPerMinute()
);
}

}
Loading

0 comments on commit 7e9e2e5

Please sign in to comment.