Search in sources :

Example 1 with ServiceBuilderDescriptorHelper

use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.

the class ServiceXmlTests method testAddSampleEntity.

@Test
public void testAddSampleEntity() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final IProject project = importProject("portlets", "com.liferay.ide.service.core.tests", "Add-Sample-Entity-Test-portlet");
    final ServiceBuilderDescriptorHelper descriptorHelper = new ServiceBuilderDescriptorHelper(project);
    assertEquals(Status.OK_STATUS, descriptorHelper.addDefaultEntity());
    final IFile serviceXmlFile = descriptorHelper.getDescriptorFile();
    final String serviceXmlContent = CoreUtil.readStreamToString(serviceXmlFile.getContents());
    final String expectedServiceXmlContent = CoreUtil.readStreamToString(this.getClass().getResourceAsStream("files/service-sample-6.2.0-add-sample-entity.xml"));
    assertEquals(expectedServiceXmlContent.replaceAll("\\s+", StringPool.SPACE), serviceXmlContent.replaceAll("\\s+", StringPool.SPACE));
}
Also used : IFile(org.eclipse.core.resources.IFile) ServiceBuilderDescriptorHelper(com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with ServiceBuilderDescriptorHelper

use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.

the class ServiceXmlTests method testAddDefaultColumns.

// This test needs to set the "liferay.bundles.dir" in the configuration.
@Test
public void testAddDefaultColumns() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final IProject project = importProject("portlets", "com.liferay.ide.service.core.tests", "Add-Default-Columns-Test-portlet");
    final ServiceBuilderDescriptorHelper descriptorHelper = new ServiceBuilderDescriptorHelper(project);
    assertEquals(Status.OK_STATUS, descriptorHelper.addEntity("AddDefaultColumns"));
    assertEquals(Status.OK_STATUS, descriptorHelper.addDefaultColumns("AddDefaultColumns"));
    final IFile serviceXmlFile = descriptorHelper.getDescriptorFile();
    final String serviceXmlContent = CoreUtil.readStreamToString(serviceXmlFile.getContents());
    final String expectedServiceXmlContent = CoreUtil.readStreamToString(this.getClass().getResourceAsStream("files/service-sample-6.2.0-add-default-columns.xml"));
    assertEquals(expectedServiceXmlContent.replaceAll("\\s+", StringPool.SPACE), serviceXmlContent.replaceAll("\\s+", StringPool.SPACE));
}
Also used : IFile(org.eclipse.core.resources.IFile) ServiceBuilderDescriptorHelper(com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 3 with ServiceBuilderDescriptorHelper

use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.

the class AddDefaultColumnsAction method run.

@Override
protected Object run(Presentation context) {
    Element element = context.part().getLocalModelElement();
    if (element instanceof Entity) {
        String entityName = ((Entity) element).getName().content();
        if (CoreUtil.isNullOrEmpty(entityName)) {
            String title = "Add Liferay Default Columns";
            String message = "The entity name must be specified.";
            MessageDialog.openInformation(UIUtil.getActiveShell(), title, message);
        } else {
            IFile serviceXML = element.adapt(IFile.class);
            new ServiceBuilderDescriptorHelper(serviceXML.getProject()).addDefaultColumns(entityName);
        }
    }
    return null;
}
Also used : Entity(com.liferay.ide.service.core.model.Entity) IFile(org.eclipse.core.resources.IFile) Element(org.eclipse.sapphire.Element) ServiceBuilderDescriptorHelper(com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper)

Example 4 with ServiceBuilderDescriptorHelper

use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.

the class AddDefaultEntityAction method run.

@Override
protected Object run(Presentation context) {
    Element localModelElement = context.part().getLocalModelElement();
    IFile serviceXML = localModelElement.adapt(IFile.class);
    new ServiceBuilderDescriptorHelper(serviceXML.getProject()).addDefaultEntity();
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) Element(org.eclipse.sapphire.Element) ServiceBuilderDescriptorHelper(com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper)

Aggregations

ServiceBuilderDescriptorHelper (com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper)4 IFile (org.eclipse.core.resources.IFile)4 IProject (org.eclipse.core.resources.IProject)2 Element (org.eclipse.sapphire.Element)2 Test (org.junit.Test)2 Entity (com.liferay.ide.service.core.model.Entity)1