Search in sources :

Example 1 with DateClass

use of com.xpn.xwiki.objects.classes.DateClass in project celements-blog by celements.

the class AddBlogDateValidationMigrator method migrate.

@Override
public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext context) throws XWikiException {
    XWikiDocument doc = context.getWiki().getDocument(((BlogClasses) blogClasses).getArticleClassRef(context.getDatabase()), context);
    BaseClass bClass = doc.getXClass();
    DateClass publishDateElement = (DateClass) bClass.get("publishdate");
    DateClass archiveDateElement = (DateClass) bClass.get("archivedate");
    publishDateElement.setValidationRegExp("/^((0[1-9]|[12][0-9]|3[01])\\.(0[1-9]|1[012])\\.([0-9]{4}) " + "([01][0-9]|2[0-4])(\\:[0-5][0-9]))$/");
    publishDateElement.setValidationMessage("cel_blog_validation_publishdate");
    publishDateElement.setDateFormat("dd.MM.yyyy HH:mm");
    archiveDateElement.setValidationRegExp("/(^$)|^((0[1-9]|[12][0-9]|3[01])\\.(0[1-9]|1[012])\\.([0-9]{4}) " + "([01][0-9]|2[0-4])(\\:[0-5][0-9]))$/");
    archiveDateElement.setValidationMessage("cel_blog_validation_archivedate");
    archiveDateElement.setDateFormat("dd.MM.yyyy HH:mm");
    context.getWiki().saveDocument(doc, context);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DateClass(com.xpn.xwiki.objects.classes.DateClass) BaseClass(com.xpn.xwiki.objects.classes.BaseClass)

Example 2 with DateClass

use of com.xpn.xwiki.objects.classes.DateClass in project xwiki-platform by xwiki.

the class DBListClassPropertyValuesProviderTest method configure.

@Before
public void configure() throws Exception {
    super.configure();
    addProperty("category", this.dbListClass, true);
    addProperty("date", new DateClass(), false);
    when(this.xcontext.getWiki().getDocument(new ClassPropertyReference("status", this.classReference), this.xcontext)).thenReturn(this.classDocument);
    this.entityReferenceSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
    this.authorExecutor = this.mocker.getInstance(AuthorExecutor.class);
    DefaultParameterizedType listQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, ListClass.class);
}
Also used : DateClass(com.xpn.xwiki.objects.classes.DateClass) AuthorExecutor(org.xwiki.security.authorization.AuthorExecutor) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) ClassPropertyReference(org.xwiki.model.reference.ClassPropertyReference) Before(org.junit.Before)

Aggregations

DateClass (com.xpn.xwiki.objects.classes.DateClass)2 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)1 Before (org.junit.Before)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 ClassPropertyReference (org.xwiki.model.reference.ClassPropertyReference)1 AuthorExecutor (org.xwiki.security.authorization.AuthorExecutor)1