Skip to content

Commit

Permalink
Merge pull request #72 from whitem4rk/docs/#71
Browse files Browse the repository at this point in the history
[Docs/#71] Add Javadoc for Blueprint
  • Loading branch information
whitem4rk authored Dec 1, 2024
2 parents 1042076 + e25bd66 commit 1fcaa1f
Show file tree
Hide file tree
Showing 24 changed files with 295 additions and 27 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.docEncoding = 'UTF-8'
options.charSet = 'UTF-8'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom config.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom container.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom host.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomHost {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom image.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomImage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom ipam.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomIpam {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom mount.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomMount {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom network.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomNetwork {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom network settings.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomNetworkSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom port.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomPort {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The type Custom volume.
*
* @author whitem4rk
* @version 1.0
* @see ProcessedData
*/
@Getter
@NoArgsConstructor
public class CustomVolume {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* The data which is used to synchronize Docker with.
* From CustomHost class to leaf, all the fields are following docker daemon API request arguments.
* If you add new features, check API documents and follow JSON key and value format.
* Also, add "custom" prefix and change key format using @JsonProperty
*
* @author whitem4rk
* @version 1.0
*/
@Getter
@NoArgsConstructor
public class ProcessedData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Request DTO which Client sends when synchronize Docker with host.
*
* @author whitem4rk
* @version 1.0
*/
@Getter
@NoArgsConstructor
public class BlueprintReqDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

import java.time.LocalDateTime;

/**
* Response DTO which client request details of blueprint.
* This DTO contains DBMS settings which should not be revealed.
*
* @author whitem4rk
* @version 1.0
* @see StorageResDto
*/
@Getter
@Setter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package api.goraebab.domain.blueprint.dto;

import api.goraebab.domain.blueprint.dockerObject.CustomHost;
import api.goraebab.domain.blueprint.dockerObject.ProcessedData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
Expand All @@ -10,6 +9,13 @@

import java.time.LocalDateTime;

/**
* Response DTO which client request list of blueprints.
* This DTO only contains necessary information.
*
* @author whitem4rk
* @version 1.0
*/
@Getter
@Setter
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* DTO that includes the success status of the container synchronization request contained in the original request.
* Note that Whether the synchronization request succeed or not, this DTO is returned.
*
* @author whitem4rk
* @version 1.0
*/
@Getter
@NoArgsConstructor
public class SyncResultDto {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/api/goraebab/domain/blueprint/entity/Blueprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import jakarta.persistence.*;
import lombok.*;

/**
* Represents a blueprint entity with information.
*
* @author whitem4rk
* @version 1.0
*/
@Getter
@Entity
@Table(name = "blueprint")
Expand Down Expand Up @@ -36,6 +42,12 @@ public void setAsRemote() {
this.isRemote = true;
}

/**
* Modify.
*
* @param name the blueprint name
* @param data the blueprint JSON format with escape handling applied.
*/
public void modify(String name, String data) {
if (name != null) {
this.name = name;
Expand All @@ -45,6 +57,14 @@ public void modify(String name, String data) {
}
}

/**
* Constructs a new instance
*
* @param name the blueprint name
* @param data the blueprint JSON format with escape handling applied.
* @param isRemote whether the blueprint is copied from remote database
* @param storage the storage to be stored
*/
@Builder
public Blueprint(String name, String data, Boolean isRemote, Storage storage) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
* Mapper interface for converting {@link Blueprint} entities to various DTOs and vice versa.
*
* @author whitem4rk
* @version 1.0
*/
@Mapper(uses = {StorageMapper.class})
public interface BlueprintMapper {

Expand All @@ -33,6 +39,13 @@ public interface BlueprintMapper {
@IterableMapping(elementTargetType = BlueprintsResDto.class)
List<BlueprintsResDto> toBlueprintsResDtoList(List<Blueprint> blueprints);

/**
* Custom mapping method to convert a JSON string into a {@link ProcessedData} object.
*
* @param data the JSON string to convert
* @return the resulting {@link ProcessedData} object
* @throws CustomException if the JSON string cannot be parsed
*/
@Named("stringToHost")
default ProcessedData stringToHost(String data) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;

/**
* A RowMapper implementation that maps a row from the result set to a {@link Blueprint} object.
*
* <p>This implementation extracts the "data" column from the
* result set and maps it to the {@code data} field in the {@link Blueprint} object.</p>
*
* @author whitem4rk
* @version 1.0
* @see org.springframework.jdbc.core.RowMapper
*/
public class BlueprintRowMapper implements RowMapper<Blueprint> {

private static final String BLUEPRINT_DATA_COLUMN_NAME = "data";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,24 @@
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
* Repository interface for managing {@link Blueprint} entities.
*
* <p>Extends the {@link JpaRepository} interface to provide CRUD operations and
* additional query methods for {@link Blueprint} objects.</p>
*
* <p>This interface is a Spring Data JPA repository and will be implemented automatically
* by Spring at runtime.</p>
*
* <p>Note: This repository currently does not include QueryDSL integration.
* If you need to perform complex dynamic queries with type safety, you may consider
* adding a custom repository interface and implementing QueryDSL functionality.</p>
*
* @author whitem4rk
* @version 1.0
* @see org.springframework.data.jpa.repository.JpaRepository
*/
@Repository
public interface BlueprintRepository extends JpaRepository<Blueprint, Long> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import api.goraebab.domain.blueprint.dto.SyncResultDto;
import java.util.List;

/**
* Service interface for managing blueprints.
* Provides methods for creating, modifying, retrieving, applying blueprints to Docker.
*
* @author whitem4rk
* @version 1.0
*/
public interface BlueprintService {

List<BlueprintsResDto> getBlueprints(Long storageId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* Implementation of the {@link BlueprintService} interface.
* This service interacts with the database using repositories and synchronizes data with Docker
* through {@link DockerSyncServiceImpl}.
*
* @author whitem4rk
* @version 1.0
*/
@Service
@RequiredArgsConstructor
public class BlueprintServiceImpl implements BlueprintService {
Expand Down Expand Up @@ -72,6 +80,14 @@ public BlueprintResDto getBlueprintById(Long storageId, Long blueprintId) {
return BlueprintMapper.INSTANCE.toBlueprintResDto(blueprint);
}

/**
* Saves a new blueprint and synchronizes it with Docker.
*
* @param storageId the ID of the storage
* @param blueprintReqDto the data of the blueprint to be saved, represented by {@link BlueprintReqDto}
* @return the result of the synchronization, represented by {@link SyncResultDto}
* @throws CustomException if saving or synchronization fails.
*/
@Override
@Transactional
public SyncResultDto saveBlueprint(Long storageId, BlueprintReqDto blueprintReqDto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
import java.util.List;
import java.util.Map;

/**
* Service interface for synchronizing Docker containers with blueprint data.
* Provides methods to manage Docker container operations based on the given processed data.
*
* @author whitem4rk
* @version 1.0
*/
public interface DockerSyncService {

List<Map<String, Object>> syncDockerWithBlueprintData(ProcessedData processedData);
Expand Down
Loading

0 comments on commit 1fcaa1f

Please sign in to comment.