-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AF-2700: Create Heatmap internal component (#1080)
* AF-2700: Create Heatmap internal component * Only used external components are exported * Review changes * Adding test for listAllComponents * Removing static functions and using a class for component Api * improving process selector * Making process selector expanded again * increasing version and removing sample logo
- Loading branch information
Showing
89 changed files
with
6,018 additions
and
1,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...nd/dashbuilder-services/src/main/java/org/dashbuilder/transfer/LayoutComponentHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2019 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dashbuilder.transfer; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.dashbuilder.external.model.ExternalComponent; | ||
import org.uberfire.ext.layout.editor.api.PerspectiveServices; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutComponent; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutRow; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutTemplate; | ||
|
||
@ApplicationScoped | ||
public class LayoutComponentHelper { | ||
|
||
@Inject | ||
private PerspectiveServices perspectiveServices; | ||
|
||
public List<String> findComponentsInTemplates(Predicate<String> pageFilter) { | ||
return perspectiveServices.listLayoutTemplates() | ||
.stream() | ||
.filter(lt -> pageFilter.test(lt.getName())) | ||
.map(LayoutTemplate::getRows) | ||
.flatMap(this::allComponentsStream) | ||
.map(lt -> lt.getProperties().get(ExternalComponent.COMPONENT_ID_KEY)) | ||
.filter(Objects::nonNull) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private Stream<LayoutComponent> allComponentsStream(List<LayoutRow> row) { | ||
return row.stream() | ||
.flatMap(r -> r.getLayoutColumns().stream()) | ||
.flatMap(cl -> Stream.concat(cl.getLayoutComponents().stream(), | ||
allComponentsStream(cl.getRows()))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...ashbuilder-services/src/test/java/org/dashbuilder/transfer/LayoutComponentHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dashbuilder.transfer; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.dashbuilder.external.model.ExternalComponent; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.uberfire.ext.layout.editor.api.PerspectiveServices; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutColumn; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutComponent; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutRow; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutTemplate; | ||
|
||
import static java.util.Collections.singletonList; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.when; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class LayoutComponentHelperTest { | ||
|
||
@Mock | ||
PerspectiveServices perspectiveServices; | ||
|
||
@InjectMocks | ||
LayoutComponentHelper layoutComponentsHelper; | ||
|
||
@Test | ||
public void testComponentId() { | ||
String c1 = "c1"; | ||
String c2 = "c2"; | ||
LayoutTemplate lt = createLayoutTemplate("lt", c1, c2); | ||
when(perspectiveServices.listLayoutTemplates()).thenReturn(singletonList(lt)); | ||
|
||
List<String> components = layoutComponentsHelper.findComponentsInTemplates(p -> true); | ||
|
||
assertEquals(2, components.size()); | ||
assertEquals(components, Arrays.asList(c1, c2)); | ||
} | ||
|
||
public void testNoComponentId() { | ||
LayoutTemplate lt = createLayoutTemplate("lt"); | ||
when(perspectiveServices.listLayoutTemplates()).thenReturn(singletonList(lt)); | ||
|
||
List<String> components = layoutComponentsHelper.findComponentsInTemplates(p -> true); | ||
|
||
assertTrue(components.isEmpty()); | ||
} | ||
|
||
public void testPageFilter() { | ||
String c1 = "c1"; | ||
LayoutTemplate lt = createLayoutTemplate("lt", c1); | ||
when(perspectiveServices.listLayoutTemplates()).thenReturn(singletonList(lt)); | ||
|
||
List<String> components = layoutComponentsHelper.findComponentsInTemplates(p -> false); | ||
|
||
assertTrue(components.isEmpty()); | ||
} | ||
|
||
private LayoutTemplate createLayoutTemplate(String name, String... componentIds) { | ||
LayoutTemplate lt = new LayoutTemplate(name); | ||
LayoutRow lr = new LayoutRow(); | ||
LayoutColumn lc = new LayoutColumn(""); | ||
|
||
lr.add(lc); | ||
lt.addRow(lr); | ||
for (String componentId : componentIds) { | ||
LayoutComponent lComp = new LayoutComponent(); | ||
lComp.addProperty(ExternalComponent.COMPONENT_ID_KEY, componentId); | ||
lc.add(lComp); | ||
} | ||
return lt; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.