Search in sources :

Example 1 with RelationshipType

use of com.enonic.xp.schema.relationship.RelationshipType in project xp by enonic.

the class XmlRelationshipTypeParserTest method assertResult.

private void assertResult() throws Exception {
    final RelationshipType result = this.builder.build();
    assertEquals("myapplication:name", result.getName().toString());
    assertEquals("description", result.getDescription());
    assertEquals("likes", result.getFromSemantic());
    assertEquals("liked by", result.getToSemantic());
    assertEquals("[myapplication:animal, myapplication:person]", result.getAllowedFromTypes().toString());
    assertEquals("[myapplication:vehicle]", result.getAllowedToTypes().toString());
}
Also used : RelationshipType(com.enonic.xp.schema.relationship.RelationshipType)

Example 2 with RelationshipType

use of com.enonic.xp.schema.relationship.RelationshipType in project xp by enonic.

the class RelationshipTypeServiceImpl method getAll.

@Override
public RelationshipTypes getAll() {
    final Set<RelationshipType> list = new LinkedHashSet<>(this.builtInTypes.getAll().getList());
    for (final Application application : this.applicationService.getInstalledApplications()) {
        final RelationshipTypes types = getByApplication(application.getKey());
        list.addAll(types.getList());
    }
    return RelationshipTypes.from(list);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RelationshipTypes(com.enonic.xp.schema.relationship.RelationshipTypes) RelationshipType(com.enonic.xp.schema.relationship.RelationshipType) Application(com.enonic.xp.app.Application)

Example 3 with RelationshipType

use of com.enonic.xp.schema.relationship.RelationshipType in project xp by enonic.

the class RelationshipTypeServiceImplTest method testSystemTypes.

@Test
public void testSystemTypes() {
    RelationshipTypes relationshipTypes = service.getAll();
    assertNotNull(relationshipTypes);
    assertEquals(2, relationshipTypes.getSize());
    relationshipTypes = service.getByApplication(ApplicationKey.SYSTEM);
    assertNotNull(relationshipTypes);
    assertEquals(2, relationshipTypes.getSize());
    RelationshipType relationshipType = service.getByName(RelationshipTypeName.PARENT);
    assertNotNull(relationshipType);
    relationshipType = service.getByName(RelationshipTypeName.REFERENCE);
    assertNotNull(relationshipType);
}
Also used : RelationshipTypes(com.enonic.xp.schema.relationship.RelationshipTypes) RelationshipType(com.enonic.xp.schema.relationship.RelationshipType) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 4 with RelationshipType

use of com.enonic.xp.schema.relationship.RelationshipType in project xp by enonic.

the class RelationshipTypeLoader method load.

@Override
protected RelationshipType load(final RelationshipTypeName name, final Resource resource) {
    final RelationshipType.Builder builder = RelationshipType.create();
    parseXml(resource, builder);
    final Instant modifiedTime = Instant.ofEpochMilli(resource.getTimestamp());
    builder.modifiedTime(modifiedTime);
    builder.createdTime(modifiedTime);
    builder.icon(loadIcon(name));
    return builder.name(name).build();
}
Also used : Instant(java.time.Instant) RelationshipType(com.enonic.xp.schema.relationship.RelationshipType)

Example 5 with RelationshipType

use of com.enonic.xp.schema.relationship.RelationshipType in project xp by enonic.

the class BuiltinRelationshipTypes method generateSystemRelationshipTypes.

private List<RelationshipType> generateSystemRelationshipTypes() {
    final List<RelationshipType> relationshipTypes = new ArrayList<>();
    for (RelationshipType relationshipType : RELATIONSHIP_TYPES) {
        relationshipType = RelationshipType.create(relationshipType).icon(loadSchemaIcon(RELATIONSHIP_TYPES_FOLDER, relationshipType.getName().getLocalName())).build();
        relationshipTypes.add(relationshipType);
    }
    return relationshipTypes;
}
Also used : RelationshipType(com.enonic.xp.schema.relationship.RelationshipType) ArrayList(java.util.ArrayList)

Aggregations

RelationshipType (com.enonic.xp.schema.relationship.RelationshipType)7 RelationshipTypes (com.enonic.xp.schema.relationship.RelationshipTypes)4 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)3 Test (org.junit.jupiter.api.Test)3 Application (com.enonic.xp.app.Application)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1