List of usage examples for com.liferay.portal.kernel.model OrganizationConstants DEFAULT_PARENT_ORGANIZATION_ID
int DEFAULT_PARENT_ORGANIZATION_ID
To view the source code for com.liferay.portal.kernel.model OrganizationConstants DEFAULT_PARENT_ORGANIZATION_ID.
Click Source Link
From source file:com.bemis.portal.customer.service.impl.CustomerProfileLocalServiceImpl.java
License:Open Source License
@Override public int countCustomer(String criteria) { long companyId = _bemisPortalService.getDefaultCompanyId(); LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put(_EXPANDO_ATTRIBUTES, criteria); return _organizationLocalService.search(companyId, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, criteria, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null).getLength(); }
From source file:com.bemis.portal.customer.service.impl.CustomerProfileLocalServiceImpl.java
License:Open Source License
@Override public List<CustomerProfile> searchCustomer(String criteria, int start, int end) throws PortalException { long companyId = _bemisPortalService.getDefaultCompanyId(); List<CustomerProfile> customerProfiles = new ArrayList<>(); LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put(_EXPANDO_ATTRIBUTES, criteria); Hits hits = _organizationLocalService.search(companyId, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, criteria, params, start, end, null); Document[] documents = hits.getDocs(); for (Document doc : documents) { long orgId = GetterUtil.getLong(doc.get(Field.ORGANIZATION_ID)); Organization org = _organizationLocalService.getOrganization(orgId); customerProfiles.add(asCustomerProfile(org)); }//from w ww . j a v a2 s . c o m return customerProfiles; }
From source file:com.bemis.portal.migration.customer.service.impl.CustomerMigrationLocalServiceImpl.java
License:Open Source License
protected Organization addOrganizationFromCustomer(long userId, CustomerOrg aCustomerOrgParent, long setPrototypeId, long parentOrganizationId) { String organizationType = OrganizationConstants.TYPE_ORGANIZATION; long statusId = ListTypeConstants.ORGANIZATION_STATUS_DEFAULT; long countryId = CountryServiceUtil.fetchCountryByA2(aCustomerOrgParent.getCountry()).getCountryId(); long regionId = RegionServiceUtil.fetchRegion(countryId, aCustomerOrgParent.getState()).getRegionId(); String bemisCustomerId = aCustomerOrgParent.getBemisCustomerId(); String bemisParentOrg = aCustomerOrgParent.getBemisParentId(); Organization anOrganization = null;/*from w w w .j a v a2 s .c o m*/ String name = ""; // @TODO Custom fields need to be finalized from the customer profile // Only parent organizations get the default and the short name if (parentOrganizationId == OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID) { name = aCustomerOrgParent.getCustomerName(); organizationType = PARENT_LOCATION_TYPE; } else { name = aCustomerOrgParent.getCustomerName() + " - " + aCustomerOrgParent.getCity(); organizationType = CUSTOMER_LOCATION_TYPE; } try { anOrganization = _organizationLocalService.getOrganization(_bemisPortalService.getDefaultCompanyId(), name); if (_log.isDebugEnabled()) { _log.debug(">>> Organization with id [" + anOrganization.getOrganizationId() + "] already exists"); } } catch (NoSuchOrganizationException nsoe) { // If we are a new organization, let us add it. try { // Create an organization with a site anOrganization = addOrganization(userId, parentOrganizationId, name, organizationType, regionId, countryId, statusId, null, true, null, bemisCustomerId, bemisParentOrg); // Now we map the site to the customer template Group organizationGroup = anOrganization.getGroup(); SitesUtil.updateLayoutSetPrototypesLinks(organizationGroup, 0, setPrototypeId, true, true); _log.debug(">>> Created an Organization with id [" + anOrganization.getOrganizationId() + "]"); } catch (Exception pe) { _log.error(pe); } } catch (PortalException pe) { _log.error(">>> Error creating Organization for Customer [" + name + "]", pe); } return anOrganization; }
From source file:com.bemis.portal.migration.customer.service.impl.CustomerMigrationLocalServiceImpl.java
License:Open Source License
protected void migrateCustomerOrgs(Date lastMigrationDate, long setPrototypeId) { // Required items to pass to Organization Service long userId = _bemisPortalService.getDefaultUser().getUserId(); // Iterate through all the parents, create them and their suborgs. List<CustomerOrg> allCustomerOrgParents = customerOrgLocalService.getAllParents(lastMigrationDate); for (CustomerOrg aCustomerOrgParent : allCustomerOrgParents) { // Lets's see what we find. if (_log.isDebugEnabled()) { _log.debug(">>> Read organization [" + aCustomerOrgParent.getCustomerName() + "] from Database"); }/*from ww w . ja v a 2 s . c o m*/ /* Save the LR version of the parent org, * Use the default parent class */ Organization aParentOrg = addOrganizationFromCustomer(userId, aCustomerOrgParent, setPrototypeId, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID); // Get the children for each parent List<CustomerOrg> allMyChildren = customerOrgLocalService .getAllChildren(aCustomerOrgParent.getBemisCustomerId()); /* If the parent has children, then create a parent-like entity * to represent location. There is always one entry returned from * this query representing the parent */ if (allMyChildren.size() > 1) { for (CustomerOrg aCustomerOrgChild : allMyChildren) { if (_log.isDebugEnabled()) { _log.debug(">>> Read organization [" + aCustomerOrgChild.getCustomerName() + "] from Database"); } addOrganizationFromCustomer(userId, aCustomerOrgChild, setPrototypeId, aParentOrg.getOrganizationId()); } } } }
From source file:com.liferay.asset.service.test.AssetCategoryLocalServiceTest.java
License:Open Source License
@Test public void testDeleteCategory() throws Exception { Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.US, RandomTestUtil.randomString()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); AssetVocabulary assetVocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(TestPropsValues.getUserId(), _group.getGroupId(), RandomTestUtil.randomString(), titleMap, null, null, serviceContext); AssetCategory assetCategory = AssetCategoryLocalServiceUtil.addCategory(TestPropsValues.getUserId(), _group.getGroupId(), RandomTestUtil.randomString(), assetVocabulary.getVocabularyId(), serviceContext);/*from ww w .jav a 2s.co m*/ serviceContext.setAssetCategoryIds(new long[] { assetCategory.getCategoryId() }); _organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(), OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), OrganizationConstants.TYPE_ORGANIZATION, 0, 0, ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, RandomTestUtil.randomString(), true, serviceContext); TestAssetIndexer testAssetIndexer = new TestAssetIndexer(); testAssetIndexer.setExpectedValues(Organization.class.getName(), _organization.getOrganizationId()); if (_organizationIndexer == null) { _organizationIndexer = IndexerRegistryUtil.getIndexer(Organization.class); } IndexerRegistryUtil.register(testAssetIndexer); AssetCategoryLocalServiceUtil.deleteCategory(assetCategory, true); }
From source file:com.liferay.asset.service.test.AssetTagLocalServiceTest.java
License:Open Source License
@Test public void testDeleteTag() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); AssetTag assetTag = AssetTagLocalServiceUtil.addTag(TestPropsValues.getUserId(), _group.getGroupId(), "Tag", serviceContext);/*from w w w. j ava 2s . c o m*/ serviceContext.setAssetTagNames(new String[] { assetTag.getName() }); _organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(), OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), OrganizationConstants.TYPE_ORGANIZATION, 0, 0, ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, RandomTestUtil.randomString(), true, serviceContext); TestAssetIndexer testAssetIndexer = new TestAssetIndexer(); testAssetIndexer.setExpectedValues(Organization.class.getName(), _organization.getOrganizationId()); if (_organizationIndexer == null) { _organizationIndexer = IndexerRegistryUtil.getIndexer(Organization.class); } IndexerRegistryUtil.register(testAssetIndexer); AssetTagLocalServiceUtil.deleteTag(assetTag); Assert.assertNull(AssetTagLocalServiceUtil.fetchAssetTag(assetTag.getTagId())); long classNameId = PortalUtil.getClassNameId(Organization.class); AssetTagStats assetTagStats = AssetTagStatsLocalServiceUtil.getTagStats(assetTag.getTagId(), classNameId); Assert.assertEquals(0, assetTagStats.getAssetCount()); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testDeleteOrganizationSiteOnlyRemovesSiteRoles() throws Exception { Organization organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(), OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), true); Group organizationSite = GroupLocalServiceUtil.getOrganizationGroup(TestPropsValues.getCompanyId(), organization.getOrganizationId()); organizationSite.setManualMembership(true); User user = UserTestUtil.addOrganizationOwnerUser(organization); UserLocalServiceUtil.addGroupUser(organizationSite.getGroupId(), user.getUserId()); UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(), new long[] { user.getUserId() }); Role siteRole = RoleTestUtil.addRole(RoleConstants.TYPE_SITE); UserGroupRoleLocalServiceUtil.addUserGroupRoles(user.getUserId(), organizationSite.getGroupId(), new long[] { siteRole.getRoleId() }); GroupLocalServiceUtil.deleteGroup(organizationSite); Assert.assertEquals(1, UserGroupRoleLocalServiceUtil.getUserGroupRolesCount(user.getUserId(), organizationSite.getGroupId())); UserLocalServiceUtil.deleteUser(user); OrganizationLocalServiceUtil.deleteOrganization(organization); }
From source file:com.liferay.users.admin.internal.exportimport.data.handler.OrganizationStagedModelDataHandler.java
License:Open Source License
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, Organization organization) throws Exception { Queue<Organization> organizations = new LinkedList<>(); organizations.add(organization);/* w ww . ja v a2 s . c o m*/ while (!organizations.isEmpty()) { Organization exportedOrganization = organizations.remove(); if (exportedOrganization .getParentOrganizationId() != OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, exportedOrganization, exportedOrganization.getParentOrganization(), PortletDataContext.REFERENCE_TYPE_PARENT); } exportAddresses(portletDataContext, exportedOrganization); exportEmailAddresses(portletDataContext, exportedOrganization); exportOrgLabors(portletDataContext, exportedOrganization); exportPasswordPolicyRel(portletDataContext, exportedOrganization); exportPhones(portletDataContext, exportedOrganization); exportWebsites(portletDataContext, exportedOrganization); Element organizationElement = portletDataContext.getExportDataElement(exportedOrganization); portletDataContext.addClassedModel(organizationElement, ExportImportPathUtil.getModelPath(exportedOrganization), exportedOrganization); organizations.addAll(exportedOrganization.getSuborganizations()); } }
From source file:com.liferay.users.admin.internal.exportimport.data.handler.OrganizationStagedModelDataHandler.java
License:Open Source License
@Override protected void importReferenceStagedModels(PortletDataContext portletDataContext, Organization organization) throws PortletDataException { if (organization.getParentOrganizationId() != OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID) { StagedModelDataHandlerUtil.importReferenceStagedModel(portletDataContext, organization, Organization.class, organization.getParentOrganizationId()); }/* w w w. ja va 2s . c om*/ }
From source file:com.liferay.users.admin.web.internal.portlet.action.EditOrganizationMVCActionCommand.java
License:Open Source License
protected Organization updateOrganization(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long organizationId = ParamUtil.getLong(actionRequest, "organizationId"); long parentOrganizationId = ParamUtil.getLong(actionRequest, "parentOrganizationSearchContainerPrimaryKeys", OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID); String name = ParamUtil.getString(actionRequest, "name"); long statusId = ParamUtil.getLong(actionRequest, "statusId"); String type = ParamUtil.getString(actionRequest, "type"); long regionId = ParamUtil.getLong(actionRequest, "regionId"); long countryId = ParamUtil.getLong(actionRequest, "countryId"); String comments = ParamUtil.getString(actionRequest, "comments"); boolean deleteLogo = ParamUtil.getBoolean(actionRequest, "deleteLogo"); byte[] logoBytes = null; long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId"); if (fileEntryId > 0) { FileEntry fileEntry = _dlAppLocalService.getFileEntry(fileEntryId); logoBytes = FileUtil.getBytes(fileEntry.getContentStream()); }//from w w w . j ava 2s .c o m boolean site = ParamUtil.getBoolean(actionRequest, "site"); List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest); List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(actionRequest); List<OrgLabor> orgLabors = UsersAdminUtil.getOrgLabors(actionRequest); List<Phone> phones = UsersAdminUtil.getPhones(actionRequest); List<Website> websites = UsersAdminUtil.getWebsites(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(Organization.class.getName(), actionRequest); Organization organization = null; if (organizationId <= 0) { // Add organization organization = _organizationService.addOrganization(parentOrganizationId, name, type, regionId, countryId, statusId, comments, site, addresses, emailAddresses, orgLabors, phones, websites, serviceContext); } else { // Update organization organization = _organizationService.updateOrganization(organizationId, parentOrganizationId, name, type, regionId, countryId, statusId, comments, !deleteLogo, logoBytes, site, addresses, emailAddresses, orgLabors, phones, websites, serviceContext); } // Layout set prototypes long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId"); long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId"); boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "publicLayoutSetPrototypeLinkEnabled", publicLayoutSetPrototypeId > 0); boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "privateLayoutSetPrototypeLinkEnabled", privateLayoutSetPrototypeId > 0); Group organizationGroup = organization.getGroup(); if (GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), organizationGroup, ActionKeys.UPDATE)) { SitesUtil.updateLayoutSetPrototypesLinks(organizationGroup, publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } // Reminder queries String reminderQueries = actionRequest.getParameter("reminderQueries"); PortletPreferences portletPreferences = organization.getPreferences(); LocalizationUtil.setLocalizedPreferencesValues(actionRequest, portletPreferences, "reminderQueries"); portletPreferences.setValue("reminderQueries", reminderQueries); portletPreferences.store(); return organization; }