use of org.iobserve.model.ModelHandlingErrorException in project iobserve-analysis by research-iobserve.
the class ModelHelper method getInternetLinkingResource.
/**
* Searches the resource environment for a linking resource with name 'Internet' and returns it,
* or creates it if it does not exist.
*
* @param environment
* the resource environment to search
* @return the found linking resource or the newly created one
*/
public static LinkingResource getInternetLinkingResource(final ResourceEnvironment environment) {
final List<LinkingResource> linkingResources = environment.getLinkingResources__ResourceEnvironment();
final Optional<LinkingResource> internetLink = linkingResources.stream().filter(link -> link.getEntityName().contains(ModelHelper.INTERNET_LINKING_RESOURCE_NAME)).findFirst();
final LinkingResource linkingResource = internetLink.orElseGet(() -> {
try {
return org.iobserve.model.factory.ResourceEnvironmentCloudFactory.createLinkingResource(environment, null, ModelHelper.INTERNET_LINKING_RESOURCE_NAME);
} catch (final ModelHandlingErrorException e) {
return null;
}
});
return linkingResource;
}
use of org.iobserve.model.ModelHandlingErrorException in project iobserve-analysis by research-iobserve.
the class ModelHelper method getInternetLinkingResource.
/**
* Searches the resource environment for a linking resource with name 'Internet' and returns it,
* or creates it if it does not exist.
*
* @param environment
* the resource environment to search
* @return the found linking resource or the newly created one
*/
public static LinkingResource getInternetLinkingResource(final ResourceEnvironment environment) {
final List<LinkingResource> linkingResources = environment.getLinkingResources__ResourceEnvironment();
final Optional<LinkingResource> internetLink = linkingResources.stream().filter(link -> link.getEntityName().contains(ModelHelper.INTERNET_LINKING_RESOURCE_NAME)).findFirst();
final LinkingResource linkingResource = internetLink.orElseGet(() -> {
try {
return org.iobserve.model.factory.ResourceEnvironmentCloudFactory.createLinkingResource(environment, null, ModelHelper.INTERNET_LINKING_RESOURCE_NAME);
} catch (final ModelHandlingErrorException e) {
return null;
}
});
return linkingResource;
}
Aggregations