use of alien4cloud.utils.version.Version in project alien4cloud by alien4cloud.
the class ToscaTypeConverterTest method convert_version_to_property_value.
@Test
public void convert_version_to_property_value() throws Exception {
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(ToscaTypes.VERSION);
PropertyValue propertyValue = converter.toPropertyValue("3.4-SNAPSHOT", propertyDefinition);
Object version = ToscaTypes.fromYamlTypeName(propertyDefinition.getType()).parse(propertyValue.getValue().toString());
assertThat(version).isInstanceOf(Version.class);
assertThat(version).isEqualTo(new Version("3.4-SNAPSHOT"));
}
use of alien4cloud.utils.version.Version in project alien4cloud by alien4cloud.
the class NodeTypeScoreService method isLatestVersion.
private boolean isLatestVersion(NodeType nodeType) {
Map<String, String[]> filters = MapUtil.newHashMap(new String[] { "elementId" }, new String[][] { new String[] { nodeType.getElementId() } });
// TODO get a single element and order by version.
Version nodeVersion = new Version(((NodeType) nodeType).getArchiveVersion());
for (Object otherVersionNodeType : alienESDAO.find(NodeType.class, filters, AlienConstants.DEFAULT_ES_SEARCH_SIZE).getData()) {
Version otherVersion = new Version(((NodeType) otherVersionNodeType).getArchiveVersion());
if (nodeVersion.compareTo(otherVersion) < 0) {
return false;
}
}
return true;
}
use of alien4cloud.utils.version.Version in project alien4cloud by alien4cloud.
the class ServiceResourceService method save.
/**
* Save the service resource and optionally checks that the name/version couple is unique.
* Check must be done for new resource or when the name or version has changed.
*
* @param serviceResource The service to save.
* @param ensureUniqueness True if we should process unicity check, false if not.
*/
public synchronized void save(ServiceResource serviceResource, boolean ensureUniqueness) {
if (ensureUniqueness) {
long count = alienDAO.buildQuery(ServiceResource.class).setFilters(fromKeyValueCouples("name", serviceResource.getName(), "version", serviceResource.getVersion())).count();
if (count > 0) {
throw new AlreadyExistException("A service with name <" + serviceResource.getName() + "> and version <" + serviceResource.getVersion() + "> already exists.");
}
}
// ensure that the nested version just reflects the version.
Version version = VersionUtil.parseVersion(serviceResource.getVersion());
serviceResource.setNestedVersion(version);
alienDAO.save(serviceResource);
publisher.publishEvent(new ServiceChangedEvent(this, serviceResource.getId()));
}
use of alien4cloud.utils.version.Version in project alien4cloud by alien4cloud.
the class AbstractToscaType method setArchiveVersion.
public void setArchiveVersion(String version) {
this.archiveVersion = version;
this.nestedVersion = new Version(version);
}
use of alien4cloud.utils.version.Version in project alien4cloud by alien4cloud.
the class Topology method setArchiveVersion.
public void setArchiveVersion(String version) {
this.archiveVersion = version;
this.nestedVersion = new Version(version);
}
Aggregations