Skip to content

Commit

Permalink
Backend endpoints for the wiki #540
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGuancheDarias committed Feb 27, 2024
1 parent 47f3f6a commit d4189f9
Show file tree
Hide file tree
Showing 76 changed files with 2,042 additions and 294 deletions.
32 changes: 31 additions & 1 deletion business/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>com.kevinguanchedarias.owge</groupId>
<artifactId>owgejava-backend</artifactId>
<version>0.11.5-SNAPSHOT</version>
<version>0.12.0-SNAPSHOT</version>
<name>OWGE Business</name>
<url>http://owgejava.kevinguanchedarias.com</url>

Expand Down Expand Up @@ -201,6 +201,36 @@
<scope>provided</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.github.docker-java/docker-java-core -->
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
<version>3.3.4</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- NOTICE: This dep is not used by owge source code, is just to override guava lib from docker-java-core, to ensure no vulnerable version is used -->
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version>
</dependency>


<!-- https://mvnrepository.com/artifact/com.github.docker-java/docker-java-transport-httpclient5 -->
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-zerodep</artifactId>
<version>3.3.4</version>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.kevinguanchedarias.owgejava.business.wiki.generator;


import com.github.dockerjava.api.DockerClient;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public class DockerWikiGenerator {
private final DockerClient dockerClient;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.kevinguanchedarias.owgejava.business.wiki.generator;

import java.nio.file.Path;
import java.util.List;

public interface WikiGenerator {
List<Path> generateFrontend(String backendUrl);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public abstract class CommonDto<K extends Serializable, E extends CommonEntity<K

@Override
public void dtoFromEntity(E entity) {
handleCommon(entity);
}

protected void handleCommon(E entity) {
id = entity.getId();
name = entity.getName();
description = entity.getDescription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class CommonDtoWithImageStore<K extends Number, E extends CommonEntityWit
@Override
public void dtoFromEntity(E entity) {
super.dtoFromEntity(entity);
handleImageLoad(entity);
}

protected void handleImageLoad(E entity) {
if (entity.getImage() != null) {
image = entity.getImage().getId();
imageUrl = entity.getImage().getUrl();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kevinguanchedarias.owgejava.dto;

import com.kevinguanchedarias.owgejava.entity.CriticalAttack;
import com.kevinguanchedarias.owgejava.util.DtoUtilService;
import lombok.*;

import java.util.List;
Expand All @@ -19,5 +20,6 @@ public class CriticalAttackDto implements DtoFromEntity<CriticalAttack> {
public void dtoFromEntity(CriticalAttack entity) {
id = entity.getId();
name = entity.getName();
entries = DtoUtilService.staticDtosFromEntities(CriticalAttackEntryDto.class, entity.getEntries());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,22 @@
package com.kevinguanchedarias.owgejava.dto;

import com.kevinguanchedarias.owgejava.entity.EntityWithImprovements;
import org.hibernate.Hibernate;
import com.kevinguanchedarias.owgejava.util.ImprovementDtoUtil;

/**
*
* @since 0.8.0
* @author Kevin Guanche Darias <[email protected]>
* @since 0.8.0
*/
public interface DtoWithImprovements {
ImprovementDto getImprovement();

void setImprovement(ImprovementDto improvementDto);

/**
*
* @since 0.8.0
* @author Kevin Guanche Darias <[email protected]>
* @since 0.8.0
*/
default <K> void dtoFromEntity(EntityWithImprovements<K> entity) {
if (Hibernate.isInitialized(entity.getImprovement()) && entity.getImprovement() != null) {
setImprovement(new ImprovementDto());
getImprovement().dtoFromEntity(entity.getImprovement());
}
setImprovement(ImprovementDtoUtil.dtoFromEntity(entity));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.kevinguanchedarias.owgejava.dto;

import com.kevinguanchedarias.owgejava.entity.ImprovementUnitType;
import lombok.Data;

@Data
public class ImprovementUnitTypeDto implements DtoFromEntity<ImprovementUnitType> {
private Integer id;
private String type;
Expand All @@ -20,83 +22,4 @@ public void dtoFromEntity(ImprovementUnitType entity) {
}
value = entity.getValue();
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

/**
* @author Kevin Guanche Darias <[email protected]>
* @deprecated Use the unit type instead
*/
@Deprecated(since = "0.9.0")
public Integer getUnitTypeId() {
return unitTypeId;
}

/**
* @author Kevin Guanche Darias <[email protected]>
* @deprecated Use the unit type instead
*/
@Deprecated(since = "0.9.0")
public void setUnitTypeId(Integer unitTypeId) {
this.unitTypeId = unitTypeId;
}

/**
* @author Kevin Guanche Darias <[email protected]>
* @deprecated Use the unit type instead
*/
@Deprecated(since = "0.9.0")
public String getUnitTypeName() {
return unitTypeName;
}

/**
* @author Kevin Guanche Darias <[email protected]>
* @deprecated Use the unit type instead
*/
@Deprecated(since = "0.9.0")
public void setUnitTypeName(String unitTypeName) {
this.unitTypeName = unitTypeName;
}

/**
* @return the unitType
* @author Kevin Guanche Darias <[email protected]>
* @since 0.9.0
*/
public UnitTypeDto getUnitType() {
return unitType;
}

/**
* @param unitType the unitType to set
* @author Kevin Guanche Darias
* @since 0.9.0
*/
public void setUnitType(UnitTypeDto unitType) {
this.unitType = unitType;
}

public Long getValue() {
return value;
}

public void setValue(Long value) {
this.value = value;
}

}
Original file line number Diff line number Diff line change
@@ -1,130 +1,40 @@
package com.kevinguanchedarias.owgejava.dto;

import com.kevinguanchedarias.owgejava.entity.Galaxy;
import com.kevinguanchedarias.owgejava.entity.Planet;
import com.kevinguanchedarias.owgejava.entity.SpecialLocation;
import lombok.Data;

/**
*
* @author Kevin Guanche Darias
* @since 0.9.0
*
*/
@Data
public class SpecialLocationDto extends CommonDtoWithImageStore<Integer, SpecialLocation>
implements DtoWithImprovements {

private ImprovementDto improvement;
private Integer galaxyId;
private String galaxyName;
private Long assignedPlanetId;
private String assignedPlanetName;

@Override
public void dtoFromEntity(SpecialLocation entity) {
super.dtoFromEntity(entity);
DtoWithImprovements.super.dtoFromEntity(entity);
Galaxy galaxy = entity.getGalaxy();
if (galaxy != null) {
galaxyId = galaxy.getId();
galaxyName = galaxy.getName();
}
Planet assignedPlanet = entity.getAssignedPlanet();
if (assignedPlanet != null) {
assignedPlanetId = assignedPlanet.getId();
assignedPlanetName = assignedPlanet.getName();
}
}

/**
* @author Kevin Guanche Darias
* @since 0.9.0
* @return the improvement
*/
@Override
public ImprovementDto getImprovement() {
return improvement;
}

/**
* @param improvement the improvement to set
* @author Kevin Guanche Darias
* @since 0.9.0
*/
@Override
public void setImprovement(ImprovementDto improvement) {
this.improvement = improvement;
}

/**
* @author Kevin Guanche Darias
* @since 0.9.0
* @return the galaxyId
*/
public Integer getGalaxyId() {
return galaxyId;
}

/**
* @param galaxyId the galaxyId to set
* @author Kevin Guanche Darias
* @since 0.9.0
*/
public void setGalaxyId(Integer galaxyId) {
this.galaxyId = galaxyId;
}

/**
* @author Kevin Guanche Darias
* @since 0.9.0
* @return the galaxyName
*/
public String getGalaxyName() {
return galaxyName;
}

/**
* @param galaxyName the galaxyName to set
* @author Kevin Guanche Darias
* @since 0.9.0
*/
public void setGalaxyName(String galaxyName) {
this.galaxyName = galaxyName;
}

/**
* @author Kevin Guanche Darias
* @since 0.9.0
* @return the assignedPlanetId
*/
public Long getAssignedPlanetId() {
return assignedPlanetId;
}

/**
* @param assignedPlanetId the assignedPlanetId to set
* @author Kevin Guanche Darias
* @since 0.9.0
*/
public void setAssignedPlanetId(Long assignedPlanetId) {
this.assignedPlanetId = assignedPlanetId;
}

/**
* @author Kevin Guanche Darias
* @since 0.9.0
* @return the assignedPlanetName
*/
public String getAssignedPlanetName() {
return assignedPlanetName;
}

/**
* @param assignedPlanetName the assignedPlanetName to set
* @author Kevin Guanche Darias
* @since 0.9.0
*/
public void setAssignedPlanetName(String assignedPlanetName) {
this.assignedPlanetName = assignedPlanetName;
}

implements DtoWithImprovements {

private ImprovementDto improvement;
private Integer galaxyId;
private String galaxyName;
private Long assignedPlanetId;
private String assignedPlanetName;

@Override
public void dtoFromEntity(SpecialLocation entity) {
super.dtoFromEntity(entity);
DtoWithImprovements.super.dtoFromEntity(entity);
loadGalaxy(entity);
Planet assignedPlanet = entity.getAssignedPlanet();
if (assignedPlanet != null) {
assignedPlanetId = assignedPlanet.getId();
assignedPlanetName = assignedPlanet.getName();
}
}

protected void loadGalaxy(SpecialLocation entity) {
var galaxy = entity.getGalaxy();
if (galaxy != null) {
galaxyId = galaxy.getId();
galaxyName = galaxy.getName();
}
}
}
Loading

0 comments on commit d4189f9

Please sign in to comment.