@Override
 public void persist() throws SystemException {
   if (this.isNew()) {
     CalendarResourceLocalServiceUtil.addCalendarResource(this);
   } else {
     CalendarResourceLocalServiceUtil.updateCalendarResource(this);
   }
 }
  public void deleteStagedModel(String uuid, long groupId, String className, String extraData)
      throws PortalException, SystemException {

    CalendarResource calendarResource =
        CalendarResourceLocalServiceUtil.fetchCalendarResourceByUuidAndGroupId(uuid, groupId);

    if (calendarResource != null) {
      CalendarResourceLocalServiceUtil.deleteCalendarResource(calendarResource);
    }
  }
  protected void initActionableDynamicQuery(ActionableDynamicQuery actionableDynamicQuery) {
    actionableDynamicQuery.setBaseLocalService(
        com.liferay.calendar.service.CalendarResourceLocalServiceUtil.getService());
    actionableDynamicQuery.setClass(CalendarResource.class);
    actionableDynamicQuery.setClassLoader(getClassLoader());

    actionableDynamicQuery.setPrimaryKeyPropertyName("calendarResourceId");
  }
  @Override
  public void onAfterUpdate(Group group) throws ModelListenerException {
    try {
      long classNameId = PortalUtil.getClassNameId(Group.class);

      CalendarResource calendarResource =
          CalendarResourceLocalServiceUtil.fetchCalendarResource(classNameId, group.getGroupId());

      if (calendarResource == null) {
        return;
      }

      calendarResource.setNameMap(group.getNameMap());

      CalendarResourceLocalServiceUtil.updateCalendarResource(calendarResource);
    } catch (Exception e) {
      throw new ModelListenerException(e);
    }
  }
  @Override
  public ActionableDynamicQuery getActionableDynamicQuery() {
    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();

    actionableDynamicQuery.setBaseLocalService(
        com.liferay.calendar.service.CalendarResourceLocalServiceUtil.getService());
    actionableDynamicQuery.setClass(CalendarResource.class);
    actionableDynamicQuery.setClassLoader(getClassLoader());

    actionableDynamicQuery.setPrimaryKeyPropertyName("calendarResourceId");

    return actionableDynamicQuery;
  }
  @Override
  public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
    IndexableActionableDynamicQuery indexableActionableDynamicQuery =
        new IndexableActionableDynamicQuery();

    indexableActionableDynamicQuery.setBaseLocalService(
        com.liferay.calendar.service.CalendarResourceLocalServiceUtil.getService());
    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
    indexableActionableDynamicQuery.setModelClass(CalendarResource.class);

    indexableActionableDynamicQuery.setPrimaryKeyPropertyName("calendarResourceId");

    return indexableActionableDynamicQuery;
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        CalendarResourceLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(
        new ActionableDynamicQuery.PerformActionMethod() {
          @Override
          public void performAction(Object object) {
            CalendarResource calendarResource = (CalendarResource) object;

            Assert.assertNotNull(calendarResource);

            count.increment();
          }
        });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
  protected void doImportStagedModel(
      PortletDataContext portletDataContext, CalendarResource calendarResource) throws Exception {

    prepareLanguagesForImport(calendarResource);

    long userId = portletDataContext.getUserId(calendarResource.getUserUuid());

    StagedModelDataHandlerUtil.importReferenceStagedModels(
        portletDataContext, calendarResource, Calendar.class);

    long classPK = getClassPK(portletDataContext, calendarResource, userId);
    Map<Locale, String> calendarResourceNameMap =
        getCalendarResourceNameMap(portletDataContext, calendarResource);

    ServiceContext serviceContext = portletDataContext.createServiceContext(calendarResource);

    CalendarResource importedCalendarResource = null;

    if (portletDataContext.isDataStrategyMirror()) {
      CalendarResource existingCalendarResource =
          CalendarResourceLocalServiceUtil.fetchCalendarResourceByUuidAndGroupId(
              calendarResource.getUuid(), portletDataContext.getScopeGroupId());

      if (existingCalendarResource == null) {
        existingCalendarResource =
            CalendarResourceLocalServiceUtil.fetchCalendarResource(
                calendarResource.getClassNameId(), classPK);
      }

      if (existingCalendarResource == null) {
        serviceContext.setUuid(calendarResource.getUuid());

        importedCalendarResource =
            CalendarResourceLocalServiceUtil.addCalendarResource(
                userId,
                portletDataContext.getScopeGroupId(),
                calendarResource.getClassNameId(),
                classPK,
                calendarResource.getClassUuid(),
                calendarResource.getCode(),
                calendarResourceNameMap,
                calendarResource.getDescriptionMap(),
                calendarResource.isActive(),
                serviceContext);
      } else {
        importedCalendarResource =
            CalendarResourceLocalServiceUtil.updateCalendarResource(
                existingCalendarResource.getCalendarResourceId(),
                calendarResource.getNameMap(),
                calendarResource.getDescriptionMap(),
                calendarResource.isActive(),
                serviceContext);
      }
    } else {
      importedCalendarResource =
          CalendarResourceLocalServiceUtil.addCalendarResource(
              userId,
              portletDataContext.getScopeGroupId(),
              calendarResource.getClassNameId(),
              classPK,
              calendarResource.getClassUuid(),
              calendarResource.getCode(),
              calendarResourceNameMap,
              calendarResource.getDescriptionMap(),
              calendarResource.isActive(),
              serviceContext);
    }

    updateCalendars(portletDataContext, calendarResource, importedCalendarResource);

    portletDataContext.importClassedModel(calendarResource, importedCalendarResource);
  }
  public Object invokeMethod(String name, String[] parameterTypes, Object[] arguments)
      throws Throwable {
    if (_methodName0.equals(name) && Arrays.deepEquals(_methodParameterTypes0, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.addCalendarResource(
          (com.liferay.calendar.model.CalendarResource) arguments[0]);
    }

    if (_methodName1.equals(name) && Arrays.deepEquals(_methodParameterTypes1, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.createCalendarResource(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName2.equals(name) && Arrays.deepEquals(_methodParameterTypes2, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.deleteCalendarResource(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName3.equals(name) && Arrays.deepEquals(_methodParameterTypes3, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.deleteCalendarResource(
          (com.liferay.calendar.model.CalendarResource) arguments[0]);
    }

    if (_methodName4.equals(name) && Arrays.deepEquals(_methodParameterTypes4, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.dynamicQuery();
    }

    if (_methodName5.equals(name) && Arrays.deepEquals(_methodParameterTypes5, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.dynamicQuery(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0]);
    }

    if (_methodName6.equals(name) && Arrays.deepEquals(_methodParameterTypes6, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.dynamicQuery(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0],
          ((Integer) arguments[1]).intValue(),
          ((Integer) arguments[2]).intValue());
    }

    if (_methodName7.equals(name) && Arrays.deepEquals(_methodParameterTypes7, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.dynamicQuery(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0],
          ((Integer) arguments[1]).intValue(),
          ((Integer) arguments[2]).intValue(),
          (com.liferay.portal.kernel.util.OrderByComparator) arguments[3]);
    }

    if (_methodName8.equals(name) && Arrays.deepEquals(_methodParameterTypes8, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.dynamicQueryCount(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0]);
    }

    if (_methodName9.equals(name) && Arrays.deepEquals(_methodParameterTypes9, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.dynamicQueryCount(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0],
          (com.liferay.portal.kernel.dao.orm.Projection) arguments[1]);
    }

    if (_methodName10.equals(name) && Arrays.deepEquals(_methodParameterTypes10, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.fetchCalendarResource(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName11.equals(name) && Arrays.deepEquals(_methodParameterTypes11, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.fetchCalendarResourceByUuidAndCompanyId(
          (java.lang.String) arguments[0], ((Long) arguments[1]).longValue());
    }

    if (_methodName12.equals(name) && Arrays.deepEquals(_methodParameterTypes12, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.fetchCalendarResourceByUuidAndGroupId(
          (java.lang.String) arguments[0], ((Long) arguments[1]).longValue());
    }

    if (_methodName13.equals(name) && Arrays.deepEquals(_methodParameterTypes13, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getCalendarResource(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName14.equals(name) && Arrays.deepEquals(_methodParameterTypes14, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getPersistedModel(
          (java.io.Serializable) arguments[0]);
    }

    if (_methodName15.equals(name) && Arrays.deepEquals(_methodParameterTypes15, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getCalendarResourceByUuidAndCompanyId(
          (java.lang.String) arguments[0], ((Long) arguments[1]).longValue());
    }

    if (_methodName16.equals(name) && Arrays.deepEquals(_methodParameterTypes16, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getCalendarResourceByUuidAndGroupId(
          (java.lang.String) arguments[0], ((Long) arguments[1]).longValue());
    }

    if (_methodName17.equals(name) && Arrays.deepEquals(_methodParameterTypes17, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getCalendarResources(
          ((Integer) arguments[0]).intValue(), ((Integer) arguments[1]).intValue());
    }

    if (_methodName18.equals(name) && Arrays.deepEquals(_methodParameterTypes18, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getCalendarResourcesCount();
    }

    if (_methodName19.equals(name) && Arrays.deepEquals(_methodParameterTypes19, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.updateCalendarResource(
          (com.liferay.calendar.model.CalendarResource) arguments[0]);
    }

    if (_methodName70.equals(name) && Arrays.deepEquals(_methodParameterTypes70, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getBeanIdentifier();
    }

    if (_methodName71.equals(name) && Arrays.deepEquals(_methodParameterTypes71, parameterTypes)) {
      CalendarResourceLocalServiceUtil.setBeanIdentifier((java.lang.String) arguments[0]);

      return null;
    }

    if (_methodName76.equals(name) && Arrays.deepEquals(_methodParameterTypes76, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.addCalendarResource(
          ((Long) arguments[0]).longValue(),
          ((Long) arguments[1]).longValue(),
          ((Long) arguments[2]).longValue(),
          ((Long) arguments[3]).longValue(),
          (java.lang.String) arguments[4],
          (java.lang.String) arguments[5],
          (java.util.Map<java.util.Locale, java.lang.String>) arguments[6],
          (java.util.Map<java.util.Locale, java.lang.String>) arguments[7],
          ((Boolean) arguments[8]).booleanValue(),
          (com.liferay.portal.service.ServiceContext) arguments[9]);
    }

    if (_methodName77.equals(name) && Arrays.deepEquals(_methodParameterTypes77, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.deleteCalendarResource(
          (com.liferay.calendar.model.CalendarResource) arguments[0]);
    }

    if (_methodName78.equals(name) && Arrays.deepEquals(_methodParameterTypes78, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.deleteCalendarResource(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName79.equals(name) && Arrays.deepEquals(_methodParameterTypes79, parameterTypes)) {
      CalendarResourceLocalServiceUtil.deleteCalendarResources(((Long) arguments[0]).longValue());

      return null;
    }

    if (_methodName80.equals(name) && Arrays.deepEquals(_methodParameterTypes80, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.fetchCalendarResource(
          ((Long) arguments[0]).longValue(), ((Long) arguments[1]).longValue());
    }

    if (_methodName81.equals(name) && Arrays.deepEquals(_methodParameterTypes81, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getCalendarResource(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName82.equals(name) && Arrays.deepEquals(_methodParameterTypes82, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.getCalendarResources(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName83.equals(name) && Arrays.deepEquals(_methodParameterTypes83, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.search(
          ((Long) arguments[0]).longValue(),
          (long[]) arguments[1],
          (long[]) arguments[2],
          (java.lang.String) arguments[3],
          (java.lang.String) arguments[4],
          (java.lang.String) arguments[5],
          ((Boolean) arguments[6]).booleanValue(),
          ((Boolean) arguments[7]).booleanValue(),
          ((Integer) arguments[8]).intValue(),
          ((Integer) arguments[9]).intValue(),
          (com.liferay.portal.kernel.util.OrderByComparator) arguments[10]);
    }

    if (_methodName84.equals(name) && Arrays.deepEquals(_methodParameterTypes84, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.searchByKeywords(
          ((Long) arguments[0]).longValue(),
          (long[]) arguments[1],
          (long[]) arguments[2],
          (java.lang.String) arguments[3],
          ((Boolean) arguments[4]).booleanValue(),
          ((Boolean) arguments[5]).booleanValue(),
          ((Integer) arguments[6]).intValue(),
          ((Integer) arguments[7]).intValue(),
          (com.liferay.portal.kernel.util.OrderByComparator) arguments[8]);
    }

    if (_methodName85.equals(name) && Arrays.deepEquals(_methodParameterTypes85, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.searchCount(
          ((Long) arguments[0]).longValue(),
          (long[]) arguments[1],
          (long[]) arguments[2],
          (java.lang.String) arguments[3],
          ((Boolean) arguments[4]).booleanValue());
    }

    if (_methodName86.equals(name) && Arrays.deepEquals(_methodParameterTypes86, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.searchCount(
          ((Long) arguments[0]).longValue(),
          (long[]) arguments[1],
          (long[]) arguments[2],
          (java.lang.String) arguments[3],
          (java.lang.String) arguments[4],
          (java.lang.String) arguments[5],
          ((Boolean) arguments[6]).booleanValue(),
          ((Boolean) arguments[7]).booleanValue());
    }

    if (_methodName87.equals(name) && Arrays.deepEquals(_methodParameterTypes87, parameterTypes)) {
      CalendarResourceLocalServiceUtil.updateAsset(
          ((Long) arguments[0]).longValue(),
          (com.liferay.calendar.model.CalendarResource) arguments[1],
          (long[]) arguments[2],
          (java.lang.String[]) arguments[3]);

      return null;
    }

    if (_methodName88.equals(name) && Arrays.deepEquals(_methodParameterTypes88, parameterTypes)) {
      return CalendarResourceLocalServiceUtil.updateCalendarResource(
          ((Long) arguments[0]).longValue(),
          (java.util.Map<java.util.Locale, java.lang.String>) arguments[1],
          (java.util.Map<java.util.Locale, java.lang.String>) arguments[2],
          ((Boolean) arguments[3]).booleanValue(),
          (com.liferay.portal.service.ServiceContext) arguments[4]);
    }

    throw new UnsupportedOperationException();
  }