use of org.guvnor.ala.ui.model.ProviderTypeKey in project kie-wb-common by kiegroup.
the class RuntimeListItemBuilder method build.
public RuntimeListItem build() {
RuntimeListItem result;
PipelineExecutionTrace pipelineTrace;
String runtimeName;
if (item.getRuntimeName() != null) {
runtimeName = item.getRuntimeName();
} else {
runtimeName = item.getRuntimeId();
}
if (item.getPipelineExecutionId() != null) {
final Pipeline pipeline = new Pipeline(new PipelineKey(item.getPipelineId()));
pipelineTrace = new PipelineExecutionTrace(new PipelineExecutionTraceKey(item.getPipelineExecutionId()));
pipelineTrace.setPipelineStatus(transformToPipelineStatus(item.getPipelineStatus()));
pipelineTrace.setPipelineError(new PipelineError(item.getPipelineError(), item.getPipelineErrorDetail()));
item.getPipelineStageItems().getItems().forEach(stage -> {
pipeline.addStage(new Stage(pipeline.getKey(), stage.getName()));
pipelineTrace.setStageStatus(stage.getName(), transformToPipelineStatus(stage.getStatus()));
pipelineTrace.setStageError(stage.getName(), new PipelineError(stage.getStageError(), stage.getStageErrorDetail()));
});
pipelineTrace.setPipeline(pipeline);
} else {
pipelineTrace = null;
}
if (item.getRuntimeId() != null) {
final Runtime runtime = new Runtime(new RuntimeKey(new ProviderKey(new ProviderTypeKey(item.getProviderTypeName(), item.getProviderVersion()), item.getProviderId()), item.getRuntimeId()), item.getRuntimeStatus(), item.getRuntimeEndpoint(), item.getStartedAt());
runtime.setPipelineTrace(pipelineTrace);
result = new RuntimeListItem(runtimeName, runtime);
} else {
result = new RuntimeListItem(runtimeName, pipelineTrace);
}
return result;
}
use of org.guvnor.ala.ui.model.ProviderTypeKey in project kie-wb-common by kiegroup.
the class ProviderConverterImpl method toModel.
/**
* @param provider A provider representation in the guvnor-ala core domain.
* @return the converted version of the provider in the format managed by the UI related modules.
*/
@Override
public Provider toModel(org.guvnor.ala.runtime.providers.Provider provider) {
Provider result = null;
if (provider != null) {
ProviderTypeKey providerTypeKey = new ProviderTypeKey(provider.getProviderType().getProviderTypeName(), provider.getProviderType().getVersion());
ProviderKey providerKey = new ProviderKey(providerTypeKey, provider.getId());
final BackendProviderHandler handler = handlerRegistry.ensureHandler(providerTypeKey);
@SuppressWarnings("unchecked") final ProviderConfiguration providerConfiguration = (ProviderConfiguration) handler.getProviderConfigConverter().toModel(provider.getConfig());
result = new Provider(providerKey, providerConfiguration);
}
return result;
}
use of org.guvnor.ala.ui.model.ProviderTypeKey in project kie-wb-common by kiegroup.
the class ProviderServiceImplTest method setUp.
@Before
public void setUp() {
providerTypeSpi = mockProviderTypeSPI("0");
providersSpi = mockProviderListSPI(providerTypeSpi, PROVIDER_COUNT);
when(runtimeProvisioningService.getProviders(anyInt(), anyInt(), anyString(), anyBoolean())).thenReturn(providersSpi);
providerTypeKey = new ProviderTypeKey(providerTypeSpi.getProviderTypeName(), providerTypeSpi.getVersion());
providerType = new ProviderType(providerTypeKey, null);
when(providerConverterFactory.getProviderConverter()).thenReturn(providerConverter);
when(providerConverterFactory.getProviderConfigConverter(providerTypeKey)).thenReturn(providerConfigConverter);
providers = new ArrayList<>();
providerKeys = new ArrayList<>();
for (int i = 0; i < PROVIDER_COUNT; i++) {
Provider provider = mock(Provider.class);
ProviderTypeKey providerTypeKey = new ProviderTypeKey(providersSpi.get(i).getProviderType().getProviderTypeName(), providersSpi.get(i).getProviderType().getVersion());
ProviderKey providerKey = new ProviderKey(providerTypeKey, providersSpi.get(i).getId());
when(provider.getKey()).thenReturn(providerKey);
providers.add(provider);
providerKeys.add(providerKey);
when(providerConverter.toModel(providersSpi.get(i))).thenReturn(provider);
}
service = new ProviderServiceImpl(runtimeProvisioningService, providerConverterFactory);
}
use of org.guvnor.ala.ui.model.ProviderTypeKey in project kie-wb-common by kiegroup.
the class ProviderServiceImplTest method testGetProviderNotExisting.
@Test
public void testGetProviderNotExisting() {
// create an arbitrary not existing key.
ProviderTypeKey providerTypeKey = new ProviderTypeKey("not exist", "not exist");
ProviderKey providerKey = new ProviderKey(providerTypeKey, "not exist");
Provider provider = service.getProvider(providerKey);
assertNull(provider);
}
use of org.guvnor.ala.ui.model.ProviderTypeKey in project kie-wb-common by kiegroup.
the class ProviderTypeServiceImplTest method testGetProviderTypeNotExisting.
@Test
public void testGetProviderTypeNotExisting() {
// invent a non existing provider type key
ProviderTypeKey providerTypeKey = new ProviderTypeKey("NonExisting", "NonExisting");
ProviderType providerType = service.getProviderType(providerTypeKey);
assertNull(providerType);
}
Aggregations