Example usage for com.liferay.portal.kernel.service OrganizationLocalServiceUtil fetchOrganizationByUuidAndCompanyId

List of usage examples for com.liferay.portal.kernel.service OrganizationLocalServiceUtil fetchOrganizationByUuidAndCompanyId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service OrganizationLocalServiceUtil fetchOrganizationByUuidAndCompanyId.

Prototype

public static com.liferay.portal.kernel.model.Organization fetchOrganizationByUuidAndCompanyId(String uuid,
        long companyId) 

Source Link

Document

Returns the organization with the matching UUID and company.

Usage

From source file:com.liferay.users.admin.internal.exportimport.data.handler.test.OrganizationStagedModelDataHandlerTest.java

License:Open Source License

@After
@Override//  www  . jav  a  2s .c om
public void tearDown() throws Exception {
    super.tearDown();

    if (_organization != null) {
        _organization = OrganizationLocalServiceUtil
                .fetchOrganizationByUuidAndCompanyId(_organization.getUuid(), _organization.getCompanyId());

        if (_organization != null) {
            deleteOrganizations(_organization);
        }
    }
}

From source file:com.liferay.users.admin.internal.exportimport.data.handler.test.OrganizationStagedModelDataHandlerTest.java

License:Open Source License

@Override
protected StagedModel getStagedModel(String uuid, Group group) {
    try {//  w  w  w  .jav a  2  s  . c  o  m
        return OrganizationLocalServiceUtil.fetchOrganizationByUuidAndCompanyId(uuid, group.getCompanyId());
    } catch (Exception e) {
        return null;
    }
}

From source file:com.liferay.users.admin.internal.exportimport.data.handler.test.OrganizationStagedModelDataHandlerTest.java

License:Open Source License

@Override
protected void validateImport(StagedModel stagedModel, StagedModelAssets stagedModelAssets,
        Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception {

    Organization organization = OrganizationLocalServiceUtil
            .fetchOrganizationByUuidAndCompanyId(stagedModel.getUuid(), group.getCompanyId());

    validateAssets(organization, stagedModelAssets, group);

    List<StagedModel> addressDependentStagedModels = dependentStagedModelsMap
            .get(Address.class.getSimpleName());

    Assert.assertEquals(addressDependentStagedModels.toString(), 1, addressDependentStagedModels.size());

    Address address = (Address) addressDependentStagedModels.get(0);

    Address importedAddress = AddressLocalServiceUtil.fetchAddressByUuidAndCompanyId(address.getUuid(),
            group.getCompanyId());//from   w w  w .j  av a  2 s .  c o m

    Assert.assertNotNull(importedAddress);
    Assert.assertEquals(organization.getOrganizationId(), importedAddress.getClassPK());

    List<StagedModel> emailAddressDependentStagedModels = dependentStagedModelsMap
            .get(EmailAddress.class.getSimpleName());

    Assert.assertEquals(emailAddressDependentStagedModels.toString(), 1,
            emailAddressDependentStagedModels.size());

    EmailAddress emailAddress = (EmailAddress) emailAddressDependentStagedModels.get(0);

    EmailAddress importedEmailAddress = EmailAddressLocalServiceUtil
            .fetchEmailAddressByUuidAndCompanyId(emailAddress.getUuid(), group.getCompanyId());

    Assert.assertNotNull(importedEmailAddress);
    Assert.assertEquals(organization.getOrganizationId(), importedEmailAddress.getClassPK());

    List<OrgLabor> importedOrgLabors = OrgLaborLocalServiceUtil.getOrgLabors(organization.getOrganizationId());

    Assert.assertEquals(importedOrgLabors.toString(), 1, importedOrgLabors.size());

    OrgLabor importedOrgLabor = importedOrgLabors.get(0);

    Assert.assertEquals(organization.getOrganizationId(), importedOrgLabor.getOrganizationId());

    List<StagedModel> passwordPolicyDependentStagedModels = dependentStagedModelsMap
            .get(PasswordPolicy.class.getSimpleName());

    Assert.assertEquals(passwordPolicyDependentStagedModels.toString(), 1,
            passwordPolicyDependentStagedModels.size());

    PasswordPolicy passwordPolicy = (PasswordPolicy) passwordPolicyDependentStagedModels.get(0);

    PasswordPolicyRel importedPasswordPolicyRel = PasswordPolicyRelLocalServiceUtil
            .fetchPasswordPolicyRel(organization.getModelClassName(), organization.getOrganizationId());

    Assert.assertNotNull(importedPasswordPolicyRel);
    Assert.assertEquals(passwordPolicy.getPasswordPolicyId(), importedPasswordPolicyRel.getPasswordPolicyId());

    List<StagedModel> phoneDependentStagedModels = dependentStagedModelsMap.get(Phone.class.getSimpleName());

    Assert.assertEquals(phoneDependentStagedModels.toString(), 1, phoneDependentStagedModels.size());

    Phone phone = (Phone) phoneDependentStagedModels.get(0);

    Phone importedPhone = PhoneLocalServiceUtil.fetchPhoneByUuidAndCompanyId(phone.getUuid(),
            group.getCompanyId());

    Assert.assertNotNull(importedPhone);
    Assert.assertEquals(organization.getOrganizationId(), importedPhone.getClassPK());

    List<StagedModel> websiteDependentStagedModels = dependentStagedModelsMap
            .get(Website.class.getSimpleName());

    Assert.assertEquals(websiteDependentStagedModels.toString(), 1, websiteDependentStagedModels.size());

    Website website = (Website) websiteDependentStagedModels.get(0);

    Website importedWebsite = WebsiteLocalServiceUtil.fetchWebsiteByUuidAndCompanyId(website.getUuid(),
            group.getCompanyId());

    Assert.assertNotNull(importedWebsite);
    Assert.assertEquals(organization.getOrganizationId(), importedWebsite.getClassPK());
}