Пример #1
0
  public CategoryEntity createCategory(
      String name,
      String parentCategoryName,
      String contentTypeName,
      String unitName,
      String ownerUid,
      String modifierUid,
      boolean autoApprove) {
    CategoryEntity category = new CategoryEntity();
    category.setKey(new CategoryKey(mockKeyService.generateNextKeySafe("TCATEGORY")));
    category.setName(name);
    if (contentTypeName != null) {
      category.setContentType(fixture.findContentTypeByName(contentTypeName));
    }
    category.setUnit(fixture.findUnitByName(unitName));
    category.setCreated(new Date());
    category.setTimestamp(new Date());
    category.setOwner(fixture.findUserByName(ownerUid));
    category.setModifier(fixture.findUserByName(modifierUid));
    category.setAutoMakeAvailable(autoApprove);
    category.setDeleted(false);

    if (parentCategoryName != null) {
      CategoryEntity parentCategory = fixture.findCategoryByName(parentCategoryName);
      category.setParent(parentCategory);
    }
    return category;
  }
Пример #2
0
 public ContentEntity createContent(
     String contentName,
     String categoryName,
     String languageCode,
     String ownerQualifiedName,
     String priority,
     Date created) {
   ContentEntity content = new ContentEntity();
   content.setLanguage(fixture.findLanguageByCode(languageCode));
   content.setCategory(fixture.findCategoryByName(categoryName));
   content.setOwner(fixture.findUserByName(ownerQualifiedName));
   content.setPriority(Integer.valueOf(priority));
   content.setCreatedAt(created); // Not-null field in database.
   content.setDeleted(false); // Not-null field in database.
   content.setName(contentName);
   return content;
 }
Пример #3
0
 public UnitEntity createUnit(String name, String languageCode) {
   UnitEntity unit = new UnitEntity();
   unit.setKey(new UnitKey(mockKeyService.generateNextKeySafe("TUNIT")));
   unit.setName(name);
   unit.setLanguage(fixture.findLanguageByCode(languageCode));
   unit.setDeleted(false);
   return unit;
 }
Пример #4
0
 public SiteEntity createSite(String name, Date timestamp, Document xmlData, String language) {
   SiteEntity site = new SiteEntity();
   site.setKey(mockKeyService.generateNextKeySafe("TMENU"));
   site.setName(name);
   site.setTimestamp(timestamp);
   site.setXmlData(xmlData);
   site.setLanguage(fixture.findLanguageByCode(language));
   return site;
 }
Пример #5
0
 public ContentTypeEntity createContentType(
     Integer key, String name, String contentHandlerClassName, Document data) {
   ContentTypeEntity contenType = new ContentTypeEntity();
   contenType.setKey(key);
   contenType.setName(name);
   contenType.setContentHandler(fixture.findContentHandlerByClassName(contentHandlerClassName));
   contenType.setTimestamp(new Date());
   contenType.setData(data);
   return contenType;
 }
Пример #6
0
 public ContentTypeEntity createContentType(
     String name, String contentHandlerClassName, Document data) {
   ContentTypeEntity contenType = new ContentTypeEntity();
   contenType.setKey(mockKeyService.generateNextKeySafe("TCONTENTTYPE"));
   contenType.setName(name);
   contenType.setContentHandler(fixture.findContentHandlerByClassName(contentHandlerClassName));
   contenType.setTimestamp(new Date());
   contenType.setData(data);
   return contenType;
 }
Пример #7
0
 public ContentAccessEntity createContentAccess(
     ContentKey contentKey, GroupEntity group, String accesses) {
   ContentEntity content = fixture.findContentByKey(contentKey);
   ContentAccessEntity access = new ContentAccessEntity();
   access.setContent(content);
   access.setGroup(group);
   access.setReadAccess(accesses.contains(ContentAccessType.READ.toString().toLowerCase()));
   access.setUpdateAccess(accesses.contains(ContentAccessType.UPDATE.toString().toLowerCase()));
   access.setDeleteAccess(accesses.contains(ContentAccessType.DELETE.toString().toLowerCase()));
   return access;
 }
Пример #8
0
 public PageTemplateEntity createPageTemplate(
     String name, PageTemplateType type, String siteName, ResourceKey stylekey) {
   PageTemplateEntity pageTemplate = new PageTemplateEntity();
   pageTemplate.setKey(mockKeyService.generateNextKeySafe("TPAGETEMPLATE"));
   pageTemplate.setName(name);
   pageTemplate.setTimestamp(new Date());
   pageTemplate.setType(type);
   pageTemplate.setSite(fixture.findSiteByName(siteName));
   pageTemplate.setRunAs(RunAsType.DEFAULT_USER);
   pageTemplate.setStyleKey(stylekey);
   return pageTemplate;
 }
Пример #9
0
 public GroupEntity createGroupInUserstore(
     String name, GroupType groupType, String userstoreName) {
   GroupEntity group = new GroupEntity();
   group.setKey(new GroupKey(Integer.toString(mockKeyService.generateNextKeySafe("TGROUP"))));
   group.setName(name);
   group.setSyncValue("sync_" + name);
   group.setDeleted(0);
   group.setRestricted(1);
   group.setType(groupType);
   group.setUserStore(fixture.findUserStoreByName(userstoreName));
   return group;
 }
Пример #10
0
 public MenuItemEntity createPageMenuItem(
     String name,
     Integer order,
     String menuName,
     String displayName,
     String site,
     String owner,
     String modifier,
     boolean hasSection,
     Boolean isOrderedSection,
     String language,
     String parentName,
     Integer parentOrder,
     Date timestamp,
     boolean isHidden,
     Document xmlData) {
   MenuItemEntity menuItem = new MenuItemEntity();
   menuItem.setKey(new MenuItemKey(mockKeyService.generateNextKeySafe("TMENUITEM")));
   menuItem.setName(name);
   menuItem.setOrder(order);
   menuItem.setMenuName(menuName);
   menuItem.setDisplayName(displayName);
   menuItem.setSite(fixture.findSiteByName(site));
   menuItem.setOwner(fixture.findUserByName(owner));
   menuItem.setModifier(fixture.findUserByName(modifier));
   menuItem.setType(MenuItemType.PAGE);
   menuItem.setSection(hasSection);
   menuItem.setOrderedSection(isOrderedSection);
   menuItem.setLanguage(fixture.findLanguageByCode(language));
   if (parentName != null) {
     menuItem.setParent(fixture.findMenuItemByName(parentName));
   }
   menuItem.setTimestamp(timestamp == null ? new Date() : timestamp);
   menuItem.setHidden(isHidden);
   menuItem.setXmlData(xmlData);
   return menuItem;
 }
Пример #11
0
  public CategoryAccessEntity createCategoryAccess(
      String categoryName, GroupEntity group, String accesses) {
    CategoryEntity category = fixture.findCategoryByName(categoryName);

    CategoryAccessEntity access = new CategoryAccessEntity();
    access.setKey(new CategoryAccessKey(category.getKey(), group.getGroupKey()));
    access.setGroup(group);
    access.setReadAccess(accesses.contains(CategoryAccessType.READ.toString().toLowerCase()));
    access.setAdminAccess(
        accesses.contains(CategoryAccessType.ADMINISTRATE.toString().toLowerCase()));
    access.setCreateAccess(accesses.contains(CategoryAccessType.CREATE.toString().toLowerCase()));
    access.setPublishAccess(accesses.contains(CategoryAccessType.APPROVE.toString().toLowerCase()));
    access.setAdminBrowseAccess(
        accesses.contains(CategoryAccessType.ADMIN_BROWSE.toString().toLowerCase()));
    return access;
  }
Пример #12
0
  public UserEntity createUser(
      String uid, String displayName, UserType type, String userStoreName, GroupEntity group) {
    UserEntity user = new UserEntity();
    user.setName(uid);
    user.setDisplayName(displayName);
    user.setSyncValue(uid);
    user.setTimestamp(new DateTime());
    user.setType(type);
    user.setDeleted(0);
    if (userStoreName != null) {
      user.setUserStore(fixture.findUserStoreByName(userStoreName));
    }
    if (group != null) {
      user.setUserGroup(group);
    }

    return user;
  }
Пример #13
0
  public UserEntity createUserWithAllValues(
      String uid, String displayName, UserType type, String userStoreName, UserInfo userInfo) {
    UserEntity user = new UserEntity();
    user.setName(uid);
    user.setDisplayName(displayName);
    user.setSyncValue(uid);
    user.setTimestamp(new DateTime());
    user.setType(type);
    user.setDeleted(0);
    if (userStoreName != null) {
      user.setUserStore(fixture.findUserStoreByName(userStoreName));
    }
    user.setUserGroup(null);

    user.setUserFields(new UserInfoTransformer().toUserFields(userInfo));

    return user;
  }
Пример #14
0
 DomainFactory(DomainFixture fixture) {
   this.fixture = fixture;
   fixture.setFactory(this);
 }
Пример #15
0
 public ContentVersionEntity createContentVersion(String status, String modiferQualifiedName) {
   ContentVersionEntity version = new ContentVersionEntity();
   version.setStatus(ContentStatus.get(Integer.valueOf(status)));
   version.setModifiedBy(fixture.findUserByName(modiferQualifiedName));
   return version;
 }
Пример #16
0
 public CategoryAccessEntity createCategoryAccessForUser(
     String categoryName, String userName, String accesses) {
   UserEntity user = fixture.findUserByName(userName);
   return createCategoryAccess(categoryName, user.getUserGroup(), accesses);
 }
Пример #17
0
  public MenuItemAccessEntity createMenuItemAccess(
      String menuItemName, int menuItemOrder, GroupEntity group, String accesses) {
    MenuItemEntity menuItem = fixture.findMenuItemByName(menuItemName);

    return createMenuItemAccess(menuItem, group, accesses);
  }
Пример #18
0
 public CategoryAccessEntity createCategoryAccessForGroup(
     String categoryName, String groupName, String accesses) {
   GroupEntity group = fixture.findGroupByName(groupName);
   return createCategoryAccess(categoryName, group, accesses);
 }