/** Sets single value of attribute of data-object. */ private void setAttribute(String attrId, String value) { Map<String, List<String>> attributes = dataObject.getAttributes(); attributes.put(attrId, singletonList(value)); } }
/** Reads single value of attribute from data-object. */ @NotNull private String getAttribute(String attrId) { Map<String, List<String>> attributes = dataObject.getAttributes(); List<String> values = attributes.get(attrId); if (values == null || values.isEmpty()) { return ""; } return firstNonNull(values.get(0), ""); }
@Override public void packagingChanged(String packaging) { Map<String, List<String>> attributes = dataObject.getAttributes(); attributes.put(PACKAGING, Arrays.asList(packaging)); if ("pom".equals(packaging)) { attributes.remove(SOURCE_FOLDER); attributes.remove(TEST_SOURCE_FOLDER); } else { attributes.put(SOURCE_FOLDER, Arrays.asList(DEFAULT_SOURCE_FOLDER)); attributes.put(TEST_SOURCE_FOLDER, Arrays.asList(DEFAULT_TEST_SOURCE_FOLDER)); } updateDelegate.updateControls(); }
/** Updates view from data-object. */ private void updateView() { Map<String, List<String>> attributes = dataObject.getAttributes(); final String artifactId = getAttribute(ARTIFACT_ID); if (!artifactId.isEmpty()) { view.setArtifactId(artifactId); } if (attributes.get(GROUP_ID) != null) { view.setGroupId(getAttribute(GROUP_ID)); } else { view.setGroupId(getAttribute(PARENT_GROUP_ID)); } if (attributes.get(VERSION) != null) { view.setVersion(getAttribute(VERSION)); } else { view.setVersion(getAttribute(PARENT_VERSION)); } view.setPackaging(getAttribute(PACKAGING)); }
/** Updates the specified {@code project} with the given {@code commands}. */ private Promise<Void> updateProject(Project project, List<CommandImpl> commands) { MutableProjectConfig config = new MutableProjectConfig(project); Map<String, List<String>> attributes = config.getAttributes(); List<String> attrValue = new ArrayList<>(attributes.size()); for (CommandImpl command : commands) { CommandDto commandDto = dtoFactory .createDto(CommandDto.class) .withName(command.getName()) .withType(command.getType()) .withCommandLine(command.getCommandLine()) .withAttributes(command.getAttributes()); attrValue.add(dtoFactory.toJson(commandDto)); } attributes.put(COMMANDS_ATTRIBUTE_NAME, attrValue); return project.update().withBody(config).send().then((Function<Project, Void>) arg -> null); }
newProject.setMixins(prevData.getMixins()); if (wizardMode == UPDATE) { newProject.setAttributes(prevData.getAttributes()); } else { final MutableProjectConfig.MutableSourceStorage sourceStorage = prevData.getSource(); Map<String, List<String>> prevDataAttributes = prevData.getAttributes(); Map<String, List<String>> newAttributes = new HashMap<>(); for (AttributeDto attribute : attributes) {
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()); }