Search in sources :

Example 1 with ServiceBuilder

use of com.liferay.ide.service.core.model.ServiceBuilder in project liferay-ide by liferay.

the class PackagePathValidationService method compute.

@Override
public Status compute() {
    ServiceBuilder serviceBuilderClass = context().find(ServiceBuilder.class);
    Value<String> packagePath = serviceBuilderClass.getPackagePath();
    String packPathVal = packagePath.content();
    if (packPathVal == null) {
        return Status.createErrorStatus(Msgs.packagePathNotEmpty);
    }
    // Use standard java conventions to validate the package name
    IStatus javaStatus = JavaConventions.validatePackageName(packPathVal, CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7);
    if (javaStatus.getSeverity() == IStatus.ERROR) {
        return Status.createErrorStatus(J2EECommonMessages.ERR_JAVA_PACAKGE_NAME_INVALID + javaStatus.getMessage());
    }
    if (javaStatus.getSeverity() == IStatus.WARNING) {
        return Status.createWarningStatus(J2EECommonMessages.ERR_JAVA_PACKAGE_NAME_WARNING + javaStatus.getMessage());
    }
    return Status.createOkStatus();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ServiceBuilder(com.liferay.ide.service.core.model.ServiceBuilder)

Example 2 with ServiceBuilder

use of com.liferay.ide.service.core.model.ServiceBuilder in project liferay-ide by liferay.

the class ToggleDiagramConnectionLabelsActionHandler method run.

@Override
protected Object run(Presentation context) {
    checked = !checked;
    ServiceBuilder serviceBuilder = (ServiceBuilder) context.part().getModelElement();
    serviceBuilder.setShowRelationshipLabels(checked);
    serviceBuilder.refresh();
    return null;
}
Also used : ServiceBuilder(com.liferay.ide.service.core.model.ServiceBuilder)

Example 3 with ServiceBuilder

use of com.liferay.ide.service.core.model.ServiceBuilder in project liferay-ide by liferay.

the class ServiceXmlTests method testEntityReferenceService.

@Test
public void testEntityReferenceService() throws Exception {
    ServiceBuilder sb = ServiceBuilder6xx.TYPE.instantiate(new RootXmlResource(new XmlResourceStore(this.getClass().getResourceAsStream("files/entity-reference-test.xml"))));
    Entity foo = sb.getEntities().get(0);
    Entity bar = sb.getEntities().get(1);
    ElementList<Relationship> relationships = sb.getRelationships();
    assertEquals(1, relationships.size());
    Entity to = sb.getRelationships().get(0).getToEntity().target();
    Entity from = sb.getRelationships().get(0).getFromEntity().target();
    assertEquals(to, foo);
    assertEquals(from, bar);
}
Also used : Entity(com.liferay.ide.service.core.model.Entity) XmlResourceStore(org.eclipse.sapphire.modeling.xml.XmlResourceStore) Relationship(com.liferay.ide.service.core.model.Relationship) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) ServiceBuilder(com.liferay.ide.service.core.model.ServiceBuilder) Test(org.junit.Test)

Example 4 with ServiceBuilder

use of com.liferay.ide.service.core.model.ServiceBuilder in project liferay-ide by liferay.

the class NamespaceValidationService method compute.

@Override
public Status compute() {
    ServiceBuilder namespaceClass = context().find(ServiceBuilder.class);
    Value<String> namespace = namespaceClass.getNamespace();
    String content = namespace.content();
    if ((content != null) && !ServiceUtil.isValidNamespace(content.toString())) {
        return Status.createErrorStatus(Msgs.namespaceElementValidKeyword);
    }
    return Status.createOkStatus();
}
Also used : ServiceBuilder(com.liferay.ide.service.core.model.ServiceBuilder)

Example 5 with ServiceBuilder

use of com.liferay.ide.service.core.model.ServiceBuilder in project liferay-ide by liferay.

the class RelationshipResource method _persistRelationship.

private void _persistRelationship() {
    Element element = parent().element();
    ServiceBuilder serviceBuilder = element.nearest(ServiceBuilder.class);
    String fromName = _relationshipObject.getFromName();
    String toName = _relationshipObject.getToName();
    Entity fromEntity = EntityRelationshipService.findEntity(fromName, serviceBuilder);
    Entity toEntity = EntityRelationshipService.findEntity(toName, serviceBuilder);
    if ((fromEntity != null) && (toEntity != null)) {
        Column primaryKeyColumn = null;
        for (Column column : toEntity.getColumns()) {
            if (column.isPrimary().content()) {
                primaryKeyColumn = column;
                break;
            }
        }
        if (primaryKeyColumn != null) {
            Column column = fromEntity.getColumns().insert();
            column.setName(primaryKeyColumn.getName().content());
            column.setType("long");
        }
    }
}
Also used : Entity(com.liferay.ide.service.core.model.Entity) Column(com.liferay.ide.service.core.model.Column) Element(org.eclipse.sapphire.Element) ServiceBuilder(com.liferay.ide.service.core.model.ServiceBuilder)

Aggregations

ServiceBuilder (com.liferay.ide.service.core.model.ServiceBuilder)5 Entity (com.liferay.ide.service.core.model.Entity)2 Column (com.liferay.ide.service.core.model.Column)1 Relationship (com.liferay.ide.service.core.model.Relationship)1 IStatus (org.eclipse.core.runtime.IStatus)1 Element (org.eclipse.sapphire.Element)1 RootXmlResource (org.eclipse.sapphire.modeling.xml.RootXmlResource)1 XmlResourceStore (org.eclipse.sapphire.modeling.xml.XmlResourceStore)1 Test (org.junit.Test)1