/** * Create SourceStorageDto DTO by using data of a github url * * @param githubUrl an instance of {@link GithubUrl} * @return newly created source storage DTO object */ public SourceStorageDto build(GithubUrl githubUrl) { // Create map for source storage dto Map<String, String> parameters = new HashMap<>(2); parameters.put("branch", githubUrl.getBranch()); if (!Strings.isNullOrEmpty(githubUrl.getSubfolder())) { parameters.put("keepDir", githubUrl.getSubfolder()); } return newDto(SourceStorageDto.class) .withLocation(githubUrl.repositoryLocation()) .withType("github") .withParameters(parameters); } }
private List<NewProjectConfigDto> asDto(List<NewProjectConfig> configList) { List<NewProjectConfigDto> result = new ArrayList<>(configList.size()); for (NewProjectConfig config : configList) { final SourceStorage source = config.getSource(); final SourceStorageDto sourceStorageDto = dtoFactory .createDto(SourceStorageDto.class) .withType(source.getType()) .withLocation(source.getLocation()) .withParameters(source.getParameters()); result.add( dtoFactory .createDto(NewProjectConfigDto.class) .withName(config.getName()) .withPath(config.getPath()) .withDescription(config.getDescription()) .withSource(sourceStorageDto) .withType(config.getType()) .withMixins(config.getMixins()) .withAttributes(config.getAttributes()) .withOptions(config.getOptions())); } return result; }
.createDto(SourceStorageDto.class) .withType(sourceStorage.getType()) .withLocation(sourceStorage.getLocation()) .withParameters(sourceStorage.getParameters());
/** Converts {@link ProjectConfig} to {@link ProjectConfigDto}. */ public static ProjectConfigDto asDto(ProjectConfig projectCfg) { final ProjectConfigDto projectConfigDto = newDto(ProjectConfigDto.class) .withName(projectCfg.getName()) .withDescription(projectCfg.getDescription()) .withPath(projectCfg.getPath()) .withType(projectCfg.getType()) .withAttributes(projectCfg.getAttributes()) .withMixins(projectCfg.getMixins()); final SourceStorage source = projectCfg.getSource(); if (source != null) { projectConfigDto.withSource( newDto(SourceStorageDto.class) .withLocation(source.getLocation()) .withType(source.getType()) .withParameters(source.getParameters())); } return projectConfigDto; }
private NewProjectConfigDto asDto(MutableProjectConfig config) { final SourceStorage source = config.getSource(); final SourceStorageDto sourceStorageDto = dtoFactory .createDto(SourceStorageDto.class) .withType(source.getType()) .withLocation(source.getLocation()) .withParameters(source.getParameters()); return dtoFactory .createDto(NewProjectConfigDto.class) .withName(config.getName()) .withPath(config.getPath()) .withDescription(config.getDescription()) .withSource(sourceStorageDto) .withType(config.getType()) .withMixins(config.getMixins()) .withAttributes(config.getAttributes()) .withOptions(config.getOptions()); }