use of org.eclipse.che.api.project.server.type.ProjectTypeDef in project che by eclipse.
the class ProjectTypesTest method testGetMixins.
@Test
public void testGetMixins() throws Exception {
Set<ProjectTypeDef> pts = new HashSet<>();
pts.add(new PrimaryType());
pts.add(new PersistedMixin());
ProjectTypeRegistry reg = new ProjectTypeRegistry(pts);
List<RegisteredProject.Problem> problems = new ArrayList<>();
ProjectTypes projectTypes = new ProjectTypes(generate("projectPath-", 5), PrimaryType.PRIMARY_ID, Collections.singletonList(PersistedMixin.PERSISTED_MIXIN_ID), reg, problems);
assertNotNull(projectTypes.getMixins());
assertEquals(projectTypes.getMixins().size(), 1);
assertTrue(projectTypes.getMixins().containsKey(PersistedMixin.PERSISTED_MIXIN_ID));
}
use of org.eclipse.che.api.project.server.type.ProjectTypeDef in project che by eclipse.
the class ProjectTypes method reset.
/**
* Reset project types and atrributes after initialization
* in case when some attributes are not valid
* (for instance required attributes are not initialized)
*
* @param attributesToDel - invalid attributes
*/
void reset(Set<Attribute> attributesToDel) {
Set<String> ptsToDel = new HashSet<>();
for (Attribute attr : attributesToDel) {
ptsToDel.add(attr.getProjectType());
}
Set<String> attrNamesToDel = new HashSet<>();
for (String pt : ptsToDel) {
ProjectTypeDef typeDef = all.get(pt);
for (Attribute attrDef : typeDef.getAttributes()) {
attrNamesToDel.add(attrDef.getName());
}
}
// remove project types
for (String typeId : ptsToDel) {
this.all.remove(typeId);
if (this.primary.getId().equals(typeId)) {
this.primary = ProjectTypeRegistry.BASE_TYPE;
this.all.put(ProjectTypeRegistry.BASE_TYPE.getId(), ProjectTypeRegistry.BASE_TYPE);
} else {
mixins.remove(typeId);
}
}
// remove attributes
for (String attr : attrNamesToDel) {
this.attributeDefs.remove(attr);
}
}
use of org.eclipse.che.api.project.server.type.ProjectTypeDef in project che by eclipse.
the class ProjectTypes method addTransient.
void addTransient(FolderEntry projectFolder) {
for (ProjectTypeDef pt : projectTypeRegistry.getProjectTypes()) {
// NOTE: Only mixable types allowed
if (pt.isMixable() && !pt.isPersisted() && pt.resolveSources(projectFolder).matched()) {
all.put(pt.getId(), pt);
mixins.put(pt.getId(), pt);
for (Attribute attr : pt.getAttributes()) {
final String attrName = attr.getName();
if (attributeDefs.containsKey(attrName)) {
problems.add(new Problem(ATTRIBUTE_NAME_PROBLEM, format("Attribute name conflict. Duplicated attributes detected for %s. " + "Attribute %s declared in %s already declared in %s. Skipped.", projectPath, attrName, pt.getId(), attributeDefs.get(attrName).getProjectType())));
}
attributeDefs.put(attrName, attr);
}
}
}
}
use of org.eclipse.che.api.project.server.type.ProjectTypeDef in project che by eclipse.
the class MavenProjectTypeTest method testGetProjectType.
@Test
public void testGetProjectType() throws Exception {
ProjectTypeDef pt = ptRegistry.getProjectType("maven");
Assert.assertTrue(pt.getAttributes().size() > 0);
Assert.assertTrue(pt.isTypeOf("java"));
}
use of org.eclipse.che.api.project.server.type.ProjectTypeDef in project che by eclipse.
the class MavenProjectTypeTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Set<ProjectTypeDef> projTypes = new HashSet<>();
projTypes.add(new JavaProjectType(new JavaValueProviderFactory()));
projTypes.add(new MavenProjectType(new MavenValueProviderFactory()));
ptRegistry = new ProjectTypeRegistry(projTypes);
Set<ProjectHandler> handlers = new HashSet<>();
handlers.add(new MavenProjectGenerator(Collections.<GeneratorStrategy>emptySet()));
httpJsonRequest = mock(HttpJsonRequest.class, new SelfReturningAnswer());
}
Aggregations