Search in sources :

Example 76 with BaseObject

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

the class PropertyChangedRuleTest method testVerifySingleObjectNotChanged.

public void testVerifySingleObjectNotChanged() throws XWikiException {
    XWikiDocument newDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
    XWikiDocument oldDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
    BaseObject oldObj = oldDoc.newObject(this.testClassName, this.context);
    BaseObject newObj = newDoc.newObject(this.testClassName, this.context);
    oldObj.setStringValue(this.testPropertyName, "value");
    newObj.setStringValue(this.testPropertyName, "value");
    this.passed = false;
    this.rule.verify(newDoc, oldDoc, this.context);
    assertFalse("My notification should not have been called", this.passed);
    // The rule should be symmetric. Do the inverse test too
    this.passed = false;
    this.rule.verify(oldDoc, newDoc, this.context);
    assertFalse("My notification should not have been called", this.passed);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 77 with BaseObject

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

the class PropertyChangedRuleTest method testVerifyObjectAdded.

public void testVerifyObjectAdded() throws XWikiException {
    XWikiDocument newDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
    XWikiDocument oldDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
    BaseObject newObj = newDoc.newObject(this.testClassName, this.context);
    newObj.setStringValue(this.testPropertyName, "value2");
    this.passed = false;
    this.rule.verify(newDoc, oldDoc, this.context);
    assertTrue("My notification should have been called", this.passed);
    // The rule should be symmetric. Do the inverse test too.
    this.passed = false;
    this.rule.verify(oldDoc, newDoc, this.context);
    assertTrue("My notification should have been called", this.passed);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 78 with BaseObject

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

the class PropertyChangedRuleTest method testVerifyMultipleObjectsPropertyNotChanged.

public void testVerifyMultipleObjectsPropertyNotChanged() throws XWikiException {
    XWikiDocument newDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
    XWikiDocument oldDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
    BaseObject newObj1 = newDoc.newObject(this.testClassName, this.context);
    newObj1.setStringValue(this.testPropertyName, "value1");
    BaseObject newObj2 = newDoc.newObject(this.testClassName, this.context);
    newObj2.setStringValue(this.testPropertyName, "value2");
    BaseObject oldObj1 = oldDoc.newObject(this.testClassName, this.context);
    oldObj1.setStringValue(this.testPropertyName, "value1");
    BaseObject oldObj2 = oldDoc.newObject(this.testClassName, this.context);
    oldObj2.setStringValue(this.testPropertyName, "value2");
    this.passed = false;
    this.rule.verify(newDoc, oldDoc, this.context);
    assertFalse("My notification should not have been called", this.passed);
    // The rule should be symmetric. Do the inverse test too.
    this.passed = false;
    this.rule.verify(oldDoc, newDoc, this.context);
    assertFalse("My notification should not have been called", this.passed);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 79 with BaseObject

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

the class SSXListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    XWikiDocument document = (XWikiDocument) source;
    String currentWiki = wikiDescriptorManager.getCurrentWikiId();
    DocumentReference ssxDocRef = new DocumentReference(currentWiki, "XWiki", "StyleSheetExtension");
    List<BaseObject> ssxObjects = document.getXObjects(ssxDocRef);
    if (ssxObjects != null && !ssxObjects.isEmpty()) {
        for (BaseObject obj : ssxObjects) {
            if (obj == null) {
                continue;
            }
            if ("LESS".equals(obj.getStringValue("contentType"))) {
                ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("code", new BaseObjectReference(ssxDocRef, obj.getNumber(), document.getDocumentReference()));
                LESSResourceReference lessResourceReference = lessResourceReferenceFactory.createReferenceForXObjectProperty(objectPropertyReference);
                lessResourcesCache.clearFromLESSResource(lessResourceReference);
                colorThemeCache.clearFromLESSResource(lessResourceReference);
            }
        }
    }
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) ObjectPropertyReference(org.xwiki.model.reference.ObjectPropertyReference) BaseObjectReference(com.xpn.xwiki.objects.BaseObjectReference) LESSResourceReference(org.xwiki.lesscss.resources.LESSResourceReference) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 80 with BaseObject

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

the class SkinListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    XWikiDocument document = (XWikiDocument) source;
    List<BaseObject> skinObjects = document.getXObjects(SKIN_CLASS);
    if (skinObjects != null && !skinObjects.isEmpty()) {
        clearCacheFromSkin(document);
        return;
    }
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) BaseObject(com.xpn.xwiki.objects.BaseObject)

Aggregations

BaseObject (com.xpn.xwiki.objects.BaseObject)484 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)309 DocumentReference (org.xwiki.model.reference.DocumentReference)225 Test (org.junit.Test)137 XWikiException (com.xpn.xwiki.XWikiException)102 XWikiContext (com.xpn.xwiki.XWikiContext)99 ArrayList (java.util.ArrayList)92 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)69 EntityReference (org.xwiki.model.reference.EntityReference)42 XWiki (com.xpn.xwiki.XWiki)41 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)40 List (java.util.List)30 Date (java.util.Date)24 BaseProperty (com.xpn.xwiki.objects.BaseProperty)23 Document (com.xpn.xwiki.api.Document)22 HashMap (java.util.HashMap)21 QueryException (org.xwiki.query.QueryException)18 AbstractComponentTest (com.celements.common.test.AbstractComponentTest)16 IOException (java.io.IOException)16 Vector (java.util.Vector)16