Java Code Examples for org.yaml.snakeyaml.nodes.Tag#MAP

The following examples show how to use org.yaml.snakeyaml.nodes.Tag#MAP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlBuildSpecMigrator.java    From onedev with MIT License 6 votes vote down vote up
private static Node migrateJobDependency(Element jobDependencyElement) {
	List<NodeTuple> tuples = new ArrayList<>();
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "jobName"), 
			new ScalarNode(Tag.STR, jobDependencyElement.elementText("jobName").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "requireSuccessful"), 
			new ScalarNode(Tag.STR, jobDependencyElement.elementText("requireSuccessful").trim())));
	Element artifactsElement = jobDependencyElement.element("artifacts");
	if (artifactsElement != null) {
		tuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "artifacts"), 
				new ScalarNode(Tag.STR, artifactsElement.getText().trim())));
	}
	
	List<Node> paramSupplyNodes = migrateParamSupplies(jobDependencyElement.element("jobParams").elements());
	if (!paramSupplyNodes.isEmpty()) {
		tuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "jobParams"), 
				new SequenceNode(Tag.SEQ, paramSupplyNodes, FlowStyle.BLOCK)));
	}
	return new MappingNode(Tag.MAP, tuples, FlowStyle.BLOCK);
}
 
Example 2
Source File: XmlBuildSpecMigrator.java    From onedev with MIT License 5 votes vote down vote up
private static Node migrateShowCondition(Element showConditionElement) {
	List<NodeTuple> tuples = new ArrayList<>();
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "inputName"), 
			new ScalarNode(Tag.STR, showConditionElement.elementText("inputName").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "valueMatcher"), 
			migrateValueMatcher(showConditionElement.element("valueMatcher"))));
	return new MappingNode(Tag.MAP, tuples, FlowStyle.BLOCK);
}
 
Example 3
Source File: XmlBuildSpecMigrator.java    From onedev with MIT License 5 votes vote down vote up
private static Node migrateCache(Element cacheElement) {
	List<NodeTuple> tuples = new ArrayList<>();
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "key"), 
			new ScalarNode(Tag.STR, cacheElement.elementText("key").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "path"), 
			new ScalarNode(Tag.STR, cacheElement.elementText("path").trim())));
	return new MappingNode(Tag.MAP, tuples, FlowStyle.BLOCK);
}
 
Example 4
Source File: XmlBuildSpecMigrator.java    From onedev with MIT License 5 votes vote down vote up
private static Node migrateProjectDependency(Element projectDependencyElement) {
	List<NodeTuple> tuples = new ArrayList<>();
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "projectName"), 
			new ScalarNode(Tag.STR, projectDependencyElement.elementText("projectName").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "buildNumber"), 
			new ScalarNode(Tag.STR, projectDependencyElement.elementText("buildNumber").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "artifacts"), 
			new ScalarNode(Tag.STR, projectDependencyElement.elementText("artifacts").trim())));

	Element authenticationElement = projectDependencyElement.element("authentication");
	if (authenticationElement != null) {
		List<NodeTuple> authenticationTuples = new ArrayList<>();
		authenticationTuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "userName"), 
				new ScalarNode(Tag.STR, authenticationElement.elementText("userName").trim())));
		authenticationTuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "passwordSecret"), 
				new ScalarNode(Tag.STR, authenticationElement.elementText("passwordSecret").trim())));
		tuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "authentication"), 
				new MappingNode(Tag.MAP, authenticationTuples, FlowStyle.BLOCK)));
	}
	return new MappingNode(Tag.MAP, tuples, FlowStyle.BLOCK);
}
 
Example 5
Source File: VersionedYamlDoc.java    From onedev with MIT License 5 votes vote down vote up
public String toYaml() {
	StringWriter writer = new StringWriter();
	DumperOptions dumperOptions = new DumperOptions();
	Serializer serializer = new Serializer(new Emitter(writer, dumperOptions), 
			new Resolver(), dumperOptions, Tag.MAP);
	try {
		serializer.open();
		serializer.serialize(this);
		serializer.close();
		return writer.toString();
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
Example 6
Source File: XmlBuildSpecMigrator.java    From onedev with MIT License 4 votes vote down vote up
private static Node migrateService(Element serviceElement) {
	List<NodeTuple> tuples = new ArrayList<>();

	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "name"), 
			new ScalarNode(Tag.STR, serviceElement.elementText("name").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "image"), 
			new ScalarNode(Tag.STR, serviceElement.elementText("image").trim())));
	Element argumentsElement = serviceElement.element("arguments");
	if (argumentsElement != null) {
		tuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "arguments"), 
				new ScalarNode(Tag.STR, argumentsElement.getText().trim())));
	}
	List<Node> envVarNodes = new ArrayList<>();
	for (Element envVarElement: serviceElement.element("envVars").elements()) {
		List<NodeTuple> envVarTuples = new ArrayList<>();
		envVarTuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "name"),
				new ScalarNode(Tag.STR, envVarElement.elementText("name").trim())));
		envVarTuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "value"),
				new ScalarNode(Tag.STR, envVarElement.elementText("value").trim())));
		envVarNodes.add(new MappingNode(Tag.MAP, envVarTuples, FlowStyle.BLOCK));
	}
	if (!envVarNodes.isEmpty()) {
		tuples.add(new NodeTuple(
				new ScalarNode(Tag.STR, "envVars"), 
				new SequenceNode(Tag.SEQ, envVarNodes, FlowStyle.BLOCK)));
	}
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "readinessCheckCommand"), 
			new ScalarNode(Tag.STR, serviceElement.elementText("readinessCheckCommand").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "cpuRequirement"), 
			new ScalarNode(Tag.STR, serviceElement.elementText("cpuRequirement").trim())));
	tuples.add(new NodeTuple(
			new ScalarNode(Tag.STR, "memoryRequirement"), 
			new ScalarNode(Tag.STR, serviceElement.elementText("memoryRequirement").trim())));
	
	return new MappingNode(Tag.MAP, tuples, FlowStyle.BLOCK);
}