Proprietà nidificate

Il valore di molte proprietà è un riferimento ad un'altra risorsa.

Se il valore di una proprietà è un riferimento ad una risorsa, PropertyRequest potrebbe contenere un oggetto NestedPropertyName invece dell'oggetto PropertyName della proprietà. L'oggetto NestedPropertyName ha un nome proprietà root e una PropertyRequest nidificata. Richiede le proprietà dalla risorsa a cui il valore proprietà denominata come root fa riferimento.

Oltre a specificare il nome della proprietà, NestedPropertyName contiene anche una propria PropertyRequest. La PropertyRequest nidificata specifica le proprietà risorsa cui fa riferimento la proprietà risorsa originale, i cui valori vengono ricavati dalla risorsa di riferimento.

Ad esempio, il seguente frammento di codice crea un elenco di nomi proprietà che identifica le proprietà CREATOR_DISPLAY_NAME, CHECKED_IN e LAST_MODIFIED, oltre al VERSION_NAME e CREATION_DATE del valore proprietà CHECKED_IN. In questo esempio il metodo nest genera e restituisce un NestedPropertyName.
PropertyRequest my_prop_request = new PropertyRequest(ControllableResource.CREATOR_DISPLAY_NAME,
     ControllableResource.CHECKED_IN.nest(
            Version.VERSION_NAME,
            Version.CREATION_DATE).
     ControllableResource.LAST_MODIFIED);
Dopo aver specificato le proprietà nidificate, è possibile richiamare il metodo doReadProperties ed accedere alle proprietà nidificate. Ad esempio:
resource = 
   (ControllableResource) resource.doReadProperties(my_prop_request);
String versionName = resource.getCheckIn().getVersionName();
// gestire le proprietà ...  

In un NestedPropertyName, la PropertyRequest che designa le proprietà da richiamare dal server può essere accresciuta con gli elementi MetaPropertyName, che consentono al client di richiedere specifiche meta proprietà di una proprietà (al posto della meta proprietà VALUE o in aggiunta ad essa).

Il valore di una proprietà che fa riferimento a un'altra risorsa è un proxy e quel proxy contiene le proprietà richieste in NestedPropertyName. Inoltre, gli elementi NestedPropertyName possono essere inclusi in una PropertyRequest per richiedere una proprietà di una risorsa, a cui fa riferimento una meta proprietà, o una meta proprietà di una proprietà a cui fa riferimento una meta proprietà. Ad esempio:
CqRecord r = p.buildProxy(CqRecord.class, "...");
FieldName<CqRecord> OWNER = new FieldName<CqRecord>("Owner");
FieldName<String> NAME = new FieldName<String>("login_name");
PropertyRequest request =
   new PropertyRequest(OWNER.nest(StpProperty.TYPE,
                                  CqFieldValue.REQUIREDNESS,
                                  StpProperty.VALUE.nest(NAME)));
CqRecord rec = (CqRecord)r.doReadProperties(request);
CqFieldValue<CqRecord> v = rec.getFieldInfo(OWNER);
String name = v.getValue().getProperty(NAME);

PropertyRequest pnl =
   new PropertyRequest(
     CqRecord.FIELDS.nest(
         StpProperty.VALUE.nest(
               StpProperty.NAME,
               StpProperty.TYPE,
               StpProperty.VALUE)));
List<CqFieldValue<?>> fields = ((CqRecord)r.doReadProperties(pnl)).getFields();
for(CqFieldValue<?> field: fields)
    System.out.println("field " + field.getName()
                       ": " + field.getType()
                       " = " + field.getValue());

La PropertyRequest nidificata in un NestedPropertyName può essa stessa contenere ulteriori oggetti NestedPropertyName. Quindi, in un'unica interazione con il server, è possibile richiamare un numero arbitrario di risorse e le relative proprietà.


Feedback