Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into bugfix/#111-improve-pe…
Browse files Browse the repository at this point in the history
…rsonnel-search
  • Loading branch information
robo-w committed Nov 25, 2021
2 parents 76f906d + 8be566b commit be2c4b3
Show file tree
Hide file tree
Showing 17 changed files with 239 additions and 489 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public AddressPoint(
this.number = number;
}

@JsonView({JsonViews.Database.class, JsonViews.PointFull.class})
public String getTitle() {
return title;
}

@JsonView({JsonViews.Database.class, JsonViews.PointFull.class})
@Override
public String getStreet() {
Expand Down Expand Up @@ -112,6 +117,11 @@ public String getCity() {
return city;
}

@JsonView({JsonViews.Database.class, JsonViews.PointFull.class})
public String getAdditional() {
return additional;
}

@JsonView(JsonViews.PointMinimal.class)
@Override
public String getInfo() {
Expand Down
5 changes: 4 additions & 1 deletion main/view/src/main/webapp/static/js/ko/bindings/ertype.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ define(["jquery", "bloodhound", "knockout", "typeahead"],
"Intensiv",
"Stroke",
"Schockraum",
"Arbeitsunfall"
"Arbeitsunfall",
"Augen",
"Dermatologie",
"HNO",
];

var bloodhound = new Bloodhound({
Expand Down
13 changes: 1 addition & 12 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@
<module>wflwr-poi</module>
<module>geobroker</module>
<module>alarm-text</module>
<module>radio</module>
</modules>

<profiles>
<profile>
<id>radio</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>radio</module>
</modules>
</profile>
</profiles>
</project>
Binary file removed plugin/radio/RXTXcomm.jar
Binary file not shown.
Binary file removed plugin/radio/librxtxSerial.so
Binary file not shown.
Binary file removed plugin/radio/librxtxSerial64.so
Binary file not shown.
8 changes: 0 additions & 8 deletions plugin/radio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,5 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<!-- GNU IO -->
<dependency>
<groupId>org.rxtx</groupId>
<artifactId>rxtx</artifactId>
<version>2.1.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Binary file removed plugin/radio/rxtxSerial64.dll
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package at.wrk.coceso.radio;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.time.Instant;

@JsonIgnoreProperties(ignoreUnknown = true)
public class IncomingMessageDto {

private String channel;
private String sender;
private Instant timestamp;
private boolean emergency;

public String getChannel() {
return channel;
}

public void setChannel(String channel) {
this.channel = channel;
}

public String getSender() {
return sender;
}

public void setSender(String sender) {
this.sender = sender;
}

public Instant getTimestamp() {
return timestamp;
}

public void setTimestamp(Instant timestamp) {
this.timestamp = timestamp;
}

public boolean isEmergency() {
return emergency;
}

public void setEmergency(boolean emergency) {
this.emergency = emergency;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package at.wrk.coceso.radio;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data/radio/messages")
public class MessageController {

private final RadioService radioService;

@Autowired
public MessageController(RadioService radioService) {
this.radioService = radioService;
}

@PostMapping
public void receiveMessage(@RequestBody IncomingMessageDto message, @RequestHeader("Authorization") String key) {
radioService.receiveMessage(message, key);
}
}
65 changes: 47 additions & 18 deletions plugin/radio/src/main/java/at/wrk/coceso/radio/RadioService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,86 @@
import at.wrk.coceso.entityevent.EntityEventFactory;
import at.wrk.coceso.entityevent.EntityEventHandler;
import at.wrk.coceso.entityevent.EntityEventListener;
import at.wrk.coceso.radio.Selcall.Direction;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.stereotype.Service;

@Service
@PropertySource(value = "classpath:ports.properties", ignoreResourceNotFound = true)
public class RadioService implements SelcallListener {
public class RadioService {

private static final Logger LOG = LoggerFactory.getLogger(RadioService.class);

@Autowired
private SelcallRepository selcallRepository;

private final TransceiverManager transceivers;
private final Map<String, Port> ports;

private final EntityEventListener<Selcall> webSocketWriter;

private final EntityEventHandler<Selcall> entityEventHandler;

private final String authToken;

@Autowired
public RadioService(Environment env, EntityEventFactory eef) {
entityEventHandler = eef.getEntityEventHandler(Selcall.class);
webSocketWriter = eef.getWebSocketWriter("/topic/radio/incoming", null, null);
entityEventHandler.addListener(webSocketWriter);
transceivers = TransceiverManager.getInstance(env, entityEventHandler);
}

@PostConstruct
private void init() {
transceivers.addListener(this);
ports = new ConcurrentHashMap<>();
try {
PropertiesLoaderUtils.loadAllProperties("ports.properties")
.forEach((path, name) -> ports.put((String) path, new Port((String) path, (String) name)));
} catch (IOException e) {
LOG.info("No port names found");
}

this.authToken = env.getProperty("radio.authenticationToken");
}

@PreDestroy
private void destroy() {
transceivers.removeListener(this);
entityEventHandler.removeListener(webSocketWriter);
}

public boolean reloadPorts() {
transceivers.reloadPorts();
// No longer implemented
return true;
}

@Override
public void saveCall(Selcall call) {
public void receiveMessage(IncomingMessageDto message, String key) {
if (authToken == null || !authToken.equals(key)) {
LOG.debug("Received call with invalid authorization key");
return;
}

LOG.debug("Call received from '{}'", message.getSender());

// Add channel to port list, if it doesn't already exist
ports.computeIfAbsent(message.getChannel(), k -> new Port(k, null));

// Transform to internal entity
Selcall call = new Selcall(
message.getChannel(),
message.getSender(),
message.isEmergency() ? Direction.RX_EMG : Direction.RX,
message.getTimestamp().atOffset(ZoneOffset.UTC)
);
entityEventHandler.entityChanged(call, 0);
selcallRepository.save(call);
}

Expand All @@ -75,10 +102,10 @@ public boolean sendSelcall(Selcall selcall) {
try {
if (port == null) {
LOG.debug("Trying to send Selcall to '{}' on all ports", ani);
transceivers.send(ani);
// No longer implemented
} else {
LOG.debug("Trying to send Selcall to '{}' on port '%s'", ani, port);
transceivers.send(port, ani);
LOG.debug("Trying to send Selcall to '{}' on port '{}'", ani, port);
// No longer implemented
}
} catch (IllegalArgumentException e) {
success = false;
Expand All @@ -92,7 +119,9 @@ public boolean sendSelcall(Selcall selcall) {
}

public List<Port> getPorts() {
return transceivers.getPorts();
return ports.values().stream()
.sorted(Comparator.comparing(Port::getPath))
.collect(Collectors.toList());
}

}
4 changes: 2 additions & 2 deletions plugin/radio/src/main/java/at/wrk/coceso/radio/Selcall.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public class Selcall implements Serializable, Comparable<Selcall> {
public Selcall() {
}

public Selcall(String port, String ani, Direction direction) {
public Selcall(String port, String ani, Direction direction, OffsetDateTime timestamp) {
this.port = port;
this.ani = ani;
this.direction = direction;
this.timestamp = OffsetDateTime.now();
this.timestamp = timestamp;
}

@Override
Expand Down

This file was deleted.

Loading

0 comments on commit be2c4b3

Please sign in to comment.