text:
package com.redhat.ceylon.compiler.typechecker.analyzer;

import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.checkAssignable;
import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.checkCasesDisjoint;
import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.checkIsExactly;
import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypedDeclaration;
import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.inSameModule;
import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.message;
import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.typeDescription;
import static com.redhat.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.typeNamesAsIntersection;
import static com.redhat.ceylon.compiler.typechecker.tree.TreeUtil.name;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.addToIntersection;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.areConsistentSupertypes;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.canonicalIntersection;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.intersectionOfSupertypes;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.isTypeUnknown;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.redhat.ceylon.compiler.typechecker.tree.Node;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.compiler.typechecker.tree.Visitor;
import com.redhat.ceylon.model.typechecker.model.Class;
import com.redhat.ceylon.model.typechecker.model.ClassOrInterface;
import com.redhat.ceylon.model.typechecker.model.Constructor;
import com.redhat.ceylon.model.typechecker.model.Declaration;
import com.redhat.ceylon.model.typechecker.model.Interface;
import com.redhat.ceylon.model.typechecker.model.Scope;
import com.redhat.ceylon.model.typechecker.model.Type;
import com.redhat.ceylon.model.typechecker.model.TypeAlias;
import com.redhat.ceylon.model.typechecker.model.TypeDeclaration;
import com.redhat.ceylon.model.typechecker.model.TypeParameter;
import com.redhat.ceylon.model.typechecker.model.TypedDeclaration;
import com.redhat.ceylon.model.typechecker.model.Unit;
import com.redhat.ceylon.model.typechecker.model.Value;

/**
 * Enforces a number of rules surrounding inheritance.
 * This work happens during an intermediate phase in
 * between the second and third phases of type analysis.
 *
 * @see TypeHierarchyVisitor for more complex stuff
 *
 * @author Gavin King
 *
 */
public class InheritanceVisitor extends Visitor {

    @Override public void visit(Tree.TypeDeclaration that) {
        validateSupertypes(that,
                that.getDeclarationModel());
        super.visit(that);
    }

    @Override public void visit(Tree.ObjectDefinition that) {
        validateSupertypes(that,
                that.getDeclarationModel()
                    .getType()
                    .getDeclaration());
        super.visit(that);
        validateEnumeratedSupertypes(that,
                that.getAnonymousClass());
    }

    @Override public void visit(Tree.ObjectArgument that) {
        validateSupertypes(that,
                that.getAnonymousClass());
        super.visit(that);
        validateEnumeratedSupertypes(that,
                that.getAnonymousClass());
    }

    @Override public void visit(Tree.ObjectExpression that) {
        validateSupertypes(that,
                that.getAnonymousClass());
        super.visit(that);
        validateEnumeratedSupertypes(that,
                that.getAnonymousClass());
    }

    @Override public void visit(Tree.TypeConstraint that) {
        super.visit(that);
        validateUpperBounds(that,
                that.getDeclarationModel());
    }

    @Override public void visit(Tree.ClassOrInterface that) {
        super.visit(that);
        validateEnumeratedSupertypeArguments(that,
                that.getDeclarationModel());
    }

    @Override public void visit(Tree.ClassDefinition that) {
        super.visit(that);
        validateEnumeratedSupertypes(that,
                that.getDeclarationModel());
    }

    @Override public void visit(Tree.InterfaceDefinition that) {
        super.visit(that);
        validateEnumeratedSupertypes(that,
                that.getDeclarationModel());
    }

    private void validateSupertypes(Node that,
            TypeDeclaration td) {
        if (!(td instanceof TypeAlias)) {
            List<Type> supertypes =
                    td.getType().getSupertypes();
            for (int i=0; i<supertypes.size(); i++) {
                Type st1 = supertypes.get(i);
                for (int j=i+1; j<supertypes.size(); j++) {
                    Type st2 = supertypes.get(j);
                    //Note: sets td.inconsistentType by side-effect
                    checkSupertypeIntersection(that,
                            td, st1, st2);
                }
            }
        }
    }
    private void checkSupertypeIntersection(Node that,
            TypeDeclaration td,
            Type st1, Type st2) {
        TypeDeclaration st1d = st1.getDeclaration();
        TypeDeclaration st2d = st2.getDeclaration();
        if (st1d.equals(st2d) /*&& !st1.isExactly(st2)*/) {
            Unit unit = that.getUnit();
            if (!areConsistentSupertypes(st1, st2, unit)) {
                that.addError(typeDescription(td, unit) +
                        " has the same parameterized supertype twice with incompatible type arguments: '" +
                        st1.asString(unit) + " & " +
                        st2.asString(unit) + "'");
               td.setInconsistentType(true);
            }
        }
    }

    private void validateUpperBounds(Tree.TypeConstraint that,
            TypeDeclaration td) {
        if (!td.isInconsistentType()) {
            Unit unit = that.getUnit();
            List<Type> upperBounds =
                    td.getSatisfiedTypes();
            List<Type> list =
                    new ArrayList<Type>
                        (upperBounds.size());
            for (Type st: upperBounds) {
                addToIntersection(list, st, unit);
            }
            if (canonicalIntersection(list, unit).isNothing()) {
                that.addError(typeDescription(td, unit) +
                        " has unsatisfiable upper bound constraints: the constraints '" +
                        typeNamesAsIntersection(upperBounds, unit) +
                        "' cannot be satisfied by any type except 'Nothing'");
            }
        }
    }

    private void validateEnumeratedSupertypes(Node that, ClassOrInterface d) {
        Type type = d.getType();
        Unit unit = that.getUnit();
        if (d instanceof Class) {
            Type superclass = d.getExtendedType();
            if (superclass!=null &&
                    superclass.isAnything() &&
                    !type.isObject() && !type.isNull()) {
                //a class which directly extends Anything
                //must be handled as a special case here
                //because of a performance optimization in
                //Class.inherits()
                that.addError("not a subtype of any case of root type: '" +
                        d.getName(unit) +
                        "' directly inherits 'Anything'");
            }
        }
        for (Type supertype: type.getSupertypes()) {
            if (!type.isExactly(supertype)) {
                TypeDeclaration std =
                        supertype.getDeclaration();
                List<Type> cts = std.getCaseTypes();
                if (cts!=null &&
                        !cts.isEmpty()) {
                    if (cts.size()==1 &&
                            cts.get(0)
                                .getDeclaration()
                                .isSelfType()) {
                        continue;
                    }
                    List<Type> types =
                            new ArrayList<Type>
                                (cts.size());
                    for (Type ct: cts) {
                        TypeDeclaration ctd =
                                ct.resolveAliases()
                                    .getDeclaration();
                        Type cst = type.getSupertype(ctd);
                        if (cst!=null) {
                            types.add(cst);
                        }
                    }
                    if (types.isEmpty()) {
                        that.addError("type is not a subtype of any case of enumerated supertype: '" +
                                d.getName(unit) +
                                "' inherits '" +
                                std.getName(unit) + "'");
                    }
                    else if (types.size()>1) {
                        StringBuilder sb = new StringBuilder();
                        for (Type pt: types) {
                            sb.append("'")
                              .append(pt.asString(unit))
                              .append("' and ");
                        }
                        sb.setLength(sb.length()-5);
                        that.addError("type is a subtype of multiple cases of enumerated supertype '" +
                                std.getName(unit) + "': '" +
                                d.getName(unit) +
                                "' inherits " + sb);
                    }
                }
            }
        }
    }

    private void validateEnumeratedSupertypeArguments(
            Node that, ClassOrInterface classOrInterface) {
        //note: I hate doing the whole traversal here, but
        //      it is the only way to get the error in the
        //      right place (see the note in visit(CaseTypes)
        //      for more)
        Type type = classOrInterface.getType();
        for (Type supertype: type.getSupertypes()) { //traverse the entire supertype hierarchy of the declaration
            if (!type.isExactly(supertype)) {
                List<Type> cts =
                        supertype.getDeclaration()
                            .getCaseTypes();
                if (cts!=null) {
                    for (Type ct: cts) {
                        if (ct.getDeclaration()
                                .equals(classOrInterface)) { //the declaration is a case of the current enumerated supertype
                            validateEnumeratedSupertypeArguments(
                                    that, classOrInterface,
                                    supertype);
                            break;
                        }
                    }
                }
            }
        }
    }

    private void validateEnumeratedSupertypeArguments(
            Node that, TypeDeclaration type,
            Type supertype) {
        List<TypeParameter> params =
                supertype.getDeclaration()
                    .getTypeParameters();
        Map<TypeParameter, Type> typeArguments =
                supertype.getTypeArguments();
        for (TypeParameter param: params) {
            Type arg = typeArguments.get(param); //the type argument that the declaration (indirectly) passes to the enumerated supertype
            if (arg!=null) {
                validateEnumeratedSupertypeArgument(that,
                        type, supertype, param, arg);
            }
        }
    }

    private void validateEnumeratedSupertypeArgument(
            Node that, TypeDeclaration type,
            Type supertype, TypeParameter tp,
            Type arg) {
        Unit unit = that.getUnit();
        if (arg.isTypeParameter()) {
            TypeParameter atp =
                    (TypeParameter)
                        arg.getDeclaration();
            if (atp.getDeclaration().equals(type)) { //the argument is a type parameter of the declaration
                //check that the variance of the argument
                //type parameter is the same as the type
                //parameter of the enumerated supertype
                if (tp.isCovariant() && !atp.isCovariant()) {
                    that.addError("argument to covariant type parameter of enumerated supertype must be covariant: " +
                            typeDescription(tp, unit));
                }
                if (tp.isContravariant() &&
                        !atp.isContravariant()) {
                    that.addError("argument to contravariant type parameter of enumerated supertype must be contravariant: " +
                            typeDescription(tp, unit));
                }
            }
            else {
                that.addError("argument to type parameter of enumerated supertype must be a type parameter of '" +
                        type.getName() + "': " +
                        typeDescription(tp, unit));
            }
        }
        else if (tp.isCovariant()) {
            if (!(arg.isNothing())) {
                //TODO: let it be the union of the lower bounds on p
                that.addError("argument to covariant type parameter of enumerated supertype must be a type parameter or 'Nothing': " +
                        typeDescription(tp, unit));
            }
        }
        else if (tp.isContravariant()) {
            List<Type> sts = tp.getSatisfiedTypes();
            //TODO: do I need to do type arg substitution here??
            Type ub = intersectionOfSupertypes(tp);
            if (!(arg.isExactly(ub))) {
                that.addError("argument to contravariant type parameter of enumerated supertype must be a type parameter or '" +
                        typeNamesAsIntersection(sts, unit) + "': " +
                        typeDescription(tp, unit));
            }
        }
        else {
            that.addError("argument to type parameter of enumerated supertype must be a type parameter: " +
                    typeDescription(tp, unit));
        }
    }

    @Override
    public void visit(Tree.ExtendedType that) {
        super.visit(that);

        TypeDeclaration td =
                (TypeDeclaration)
                    that.getScope();
        if (!td.isAlias()) {
            Tree.SimpleType et = that.getType();
            if (et!=null) {
                Tree.InvocationExpression ie =
                        that.getInvocationExpression();
                Class clazz = (Class) td;
                boolean hasConstructors =
                        clazz.hasConstructors() ||
                        clazz.hasEnumerated();
                boolean anonymous = clazz.isAnonymous();
                if (ie==null) {
                    if (!hasConstructors || anonymous) {
                        et.addError("missing instantiation arguments");
                    }
                }
                else {
                    if (hasConstructors && !anonymous) {
                        et.addError("unnecessary instantiation arguments");
                    }
                }

                Unit unit = that.getUnit();

                Type type = et.getTypeModel();
                if (type!=null) {
                    checkSelfTypes(et, td, type);
                    checkExtensionOfMemberType(et, td, type);
                    //checkCaseOfSupertype(et, td, type);
                    Type ext = td.getExtendedType();
                    TypeDeclaration etd =
                            ext==null ? null :
                                ext.getDeclaration();
                    TypeDeclaration aetd =
                            type.getDeclaration();
                    if (aetd instanceof Constructor &&
                            aetd.isAbstract()) {
                        et.addError("extends a partial constructor: '" +
                                aetd.getName(unit) +
                                "' is declared abstract");
                    }
                    while (etd!=null && etd.isAlias()) {
                        Type etdet =
                                etd.getExtendedType();
                        etd = etdet == null ? null :
                            etdet.getDeclaration();
                    }
                    if (etd!=null) {
                        if (etd.isFinal()) {
                            et.addError("extends a final class: '" +
                                    etd.getName(unit) +
                                    "' is declared final");
                        }
                        if (etd.isSealed() &&
                                !inSameModule(etd, unit)) {
                            String moduleName =
                                    etd.getUnit()
                                        .getPackage()
                                        .getModule()
                                        .getNameAsString();
                            et.addError("extends a sealed class in a different module: '" +
                                    etd.getName(unit) +
                                    "' in '" + moduleName +
                                    "' is sealed");
                        }
                    }
                }
                checkSupertypeVarianceAnnotations(et);
            }
        }
    }

    @Override
    public void visit(Tree.SatisfiedTypes that) {
        super.visit(that);
        TypeDeclaration td =
                (TypeDeclaration)
                    that.getScope();
        if (td.isAlias()) {
            return;
        }
        Set<TypeDeclaration> set =
                new HashSet<TypeDeclaration>();
        if (td.getSatisfiedTypes().isEmpty()) {
            return; //handle undecidable case
        }

        Unit unit = that.getUnit();

        for (Tree.StaticType t: that.getTypes()) {
            Type type = t.getTypeModel();
            if (!isTypeUnknown(type)) {
                type = type.resolveAliases();
                TypeDeclaration dec = type.getDeclaration();
                if (td instanceof ClassOrInterface &&
                        !unit.getPackage()
                           .getModule()
                           .isLanguageModule()) {
                    if (unit.isCallableType(type)) {
                        t.addError("satisfies 'Callable'");
                    }
                    TypeDeclaration cad =
                            unit.getConstrainedAnnotationDeclaration();
                    if (dec.equals(cad)) {
                        t.addError("directly satisfies 'ConstrainedAnnotation'");
                    }
                }
                if (!set.add(dec)) {
                    //this error is not really truly necessary
                    //but the spec says it is an error, and
                    //the backend doesn't like it
                    t.addError("duplicate satisfied type: '" +
                            dec.getName(unit) + "' of '" +
                            td.getName() + "'");
                }
                if (td instanceof ClassOrInterface) {
                    TypeDeclaration std =
                            dec;
                    if (std.isSealed() &&
                            !inSameModule(std, unit)) {
                        String moduleName =
                                std.getUnit()
                                    .getPackage()
                                    .getModule()
                                    .getNameAsString();
                        t.addError("satisfies a sealed interface in a different module: '" +
                                std.getName(unit) + "' in '" +
                                moduleName + "'");
                    }
                }
                checkSelfTypes(t, td, type);
                checkExtensionOfMemberType(t, td, type);
                /*if (!(td instanceof TypeParameter)) {
                    checkCaseOfSupertype(t, td, type);
                }*/
            }
            if (t instanceof Tree.SimpleType) {
                Tree.SimpleType st = (Tree.SimpleType) t;
                checkSupertypeVarianceAnnotations(st);
            }
        }
    }

    @Override
    public void visit(Tree.CaseTypes that) {
        super.visit(that);

        //this forces every case to be a subtype of the
        //enumerated type, so that we can make use of the
        //enumerated type is equivalent to its cases
        TypeDeclaration td =
                (TypeDeclaration)
                    that.getScope();

        //TODO: get rid of this awful hack:
        List<Type> cases = td.getCaseTypes();
        td.setCaseTypes(null);

        if (td instanceof TypeParameter) {
            for (Tree.StaticType t: that.getTypes()) {
                for (Tree.StaticType ot: that.getTypes()) {
                    if (t==ot) break;
                    checkCasesDisjoint(
                            t.getTypeModel(),
                            ot.getTypeModel(),
                            ot);
                }
            }
        }
        else {
            collectCaseTypes(that, td);
            collectCaseValues(that, td);
        }

        //TODO: get rid of this awful hack:
        td.setCaseTypes(cases);
    }

    void collectCaseValues(Tree.CaseTypes that,
            TypeDeclaration td) {
        Unit unit = that.getUnit();
        Set<Declaration> valueSet =
                new HashSet<Declaration>();
        for (Tree.BaseMemberExpression bme:
                that.getBaseMemberExpressions()) {
            TypedDeclaration value =
                    getTypedDeclaration(bme.getScope(),
                            name(bme.getIdentifier()),
                            null, false, unit);
            if (value!=null) {
                if (value!=null && !valueSet.add(value)) {
                    //this error is not really truly necessary
                    bme.addError("duplicate case: '" +
                            value.getName(unit) +
                            "' of '" + td.getName() + "'");
                }
                Type type = value.getType();
                if (type!=null) {
                    TypeDeclaration caseDec =
                            type.getDeclaration();
                    if (caseDec instanceof Constructor) {
                        Scope scope = caseDec.getContainer();
                        if (scope instanceof Class) {
                            //enumerated singleton constructors
                            Constructor cons =
                                    (Constructor) caseDec;
                            Class c = (Class) scope;
                            if (!c.isToplevel()) {
                                bme.addError("case must be a value constructor of a toplevel class: '" +
                                        c.getName(unit) +
                                        "' is not toplevel");
                            }
                            else if (!cons.getParameterLists().isEmpty()) {
                                bme.addError("case must be a value constructor of a toplevel class: '" +
                                        cons.getName(unit) +
                                        "' is not a value constructor");
                            }
                            /*else if (!c.inherits(unit.getIdentifiableDeclaration())) {
                                bme.addError("case must be a value constructor of an identifiable class: '" +
                                        c.getName(unit) +
                                        "' is not a subtype of 'Identifiable'");
                            }*/
                        }
                    }
                    else {
                        //enumerated anonymous subclasses
                        if (!caseDec.isObjectClass()) {
                            bme.addError("case must be a toplevel anonymous class: '" +
                                    value.getName(unit) +
                                    "' is not an anonymous class");
                        }
                        else if (!value.isToplevel()) {
                            bme.addError("case must be a toplevel anonymous class: '" +
                                    value.getName(unit) +
                                    "' is not toplevel");
                        }
                    }
                    if (checkDirectSubtype(td, bme, type)) {
                        checkAssignable(type, td.getType(), bme,
                                getCaseTypeExplanation(td, type));
                    }
                }
            }
        }
    }

    void collectCaseTypes(Tree.CaseTypes that, TypeDeclaration td) {
        Set<TypeDeclaration> typeSet =
                new HashSet<TypeDeclaration>();
        for (Tree.StaticType ct: that.getTypes()) {
            Type type = ct.getTypeModel();
            if (!isTypeUnknown(type)) {
                type = type.resolveAliases();
                TypeDeclaration ctd = type.getDeclaration();
                if (!typeSet.add(ctd)) {
                    //this error is not really truly necessary
                    Unit unit = that.getUnit();
                    ct.addError("duplicate case type: '" +
                            ctd.getName(unit) + "' of '" +
                            td.getName() + "'");
                }
                if (!(ctd instanceof TypeParameter)) {
                    //it's not a self type
                    if (checkDirectSubtype(td, ct, type)) {
                        checkAssignable(type, td.getType(), ct,
                                getCaseTypeExplanation(td, type));
                    }
                    //note: this is a better, faster way to call
                    //      validateEnumeratedSupertypeArguments()
                    //      but unfortunately it winds up displaying
                    //      the error on the wrong node, confusing
                    //      the user
                    /*
                    Type supertype =
                            type.getDeclaration()
                                .getType()
                                .getSupertype(td);
                    validateEnumeratedSupertypeArguments(t,
                            type.getDeclaration(), supertype);
                    */
                }
                checkCaseType(td, ct, ctd);
            }
        }
    }

    void checkCaseType(TypeDeclaration type,
            Tree.StaticType ct,
            TypeDeclaration caseTypeDec) {
        if (caseTypeDec instanceof ClassOrInterface &&
                ct instanceof Tree.SimpleType) {
            Tree.SimpleType t = (Tree.SimpleType) ct;
            Tree.TypeArgumentList tal =
                    t.getTypeArgumentList();
            if (tal!=null) {
                List<Tree.Type> args =
                        tal.getTypes();
                List<TypeParameter> typeParameters =
                        caseTypeDec.getTypeParameters();
                Set<TypeParameter> used =
                        new HashSet<TypeParameter>();
                for (int i=0;
                        i<args.size() &&
                        i<typeParameters.size();
                        i++) {
                    Tree.Type arg = args.get(i);
                    TypeParameter typeParameter =
                            caseTypeDec.getTypeParameters()
                                .get(i);
                    Type argType = arg.getTypeModel();
                    if (argType!=null) {
                        TypeDeclaration argTypeDec =
                                argType.getDeclaration();
                        if (argType.isTypeParameter()) {
                            TypeParameter tp =
                                    (TypeParameter)
                                        argTypeDec;
                            if (!tp.getDeclaration()
                                    .equals(type)) {
                                arg.addError("type argument is not a type parameter of the enumerated type: '" +
                                        tp.getName() +
                                        "' is not a type parameter of '" +
                                        type.getName());
                            }
                            else if (!used.add(tp)) {
                                arg.addError("type parameter of the enumerated type is used twice as a type argument: '" +
                                        argTypeDec.getName());
                            }
                        }
                        else if (typeParameter.isCovariant()) {
                            checkAssignable(
                                    typeParameter.getType(),
                                    argType, arg,
                                    "type argument not an upper bound of the type parameter");
                        }
                        else if (typeParameter.isContravariant()) {
                            checkAssignable(argType,
                                    typeParameter.getType(), arg,
                                    "type argument not a lower bound of the type parameter");
                        }
                        else {
                            arg.addError("type argument is not a type parameter of the enumerated type: '" +
                                    argTypeDec.getName() + "'");
                        }
                    }
                }
            }
        }
    }

    @Override
    public void visit(Tree.DelegatedConstructor that) {
        super.visit(that);

        TypeDeclaration constructor =
                (TypeDeclaration)
                    that.getScope();
        Scope container = constructor.getContainer();
        Tree.SimpleType type = that.getType();
        if (type!=null &&
                constructor instanceof Constructor &&
                container instanceof Class) {
            Class containingClass = (Class) container;
            Type et = containingClass.getExtendedType();
            if (et!=null) {
                Unit unit = that.getUnit();
                Type extendedType =
                        containingClass.getExtendedType();
                Type constructedType =
                        type.getTypeModel();
                Declaration delegate =
                        type.getDeclarationModel();
                TypeDeclaration superclass =
                        et.getDeclaration();
                if (superclass instanceof Constructor) {
                    superclass =
                            superclass.getExtendedType()
                                .getDeclaration();
                }
                if (delegate instanceof Constructor) {
                    Constructor c = (Constructor) delegate;
                    if (c.equals(constructor)) {
                        type.addError("constructor delegates to itself: '" +
                                c.getName() + "'");
                    }
                    Type delegatedType = c.getExtendedType();
                    TypeDeclaration delegated =
                            delegatedType == null ? null :
                                delegatedType.getDeclaration();
                    if (superclass.equals(delegated)) {
                        checkIsExactly(
                                constructedType.getExtendedType(),
                                extendedType, type,
                                "type arguments must match type arguments in extended class expression");
                    }
                    else if (containingClass.equals(delegated)) {
                        if (type instanceof Tree.QualifiedType) {
                            Tree.QualifiedType qt =
                                    (Tree.QualifiedType)
                                        type;
                            checkIsExactly(
                                    constructedType.getQualifyingType(),
                                    containingClass.getType(),
                                    qt.getOuterType(),
                                    "type arguments must be the type parameters of this class");
                        }
                    }
                    else {
                        type.addError("not a constructor of the immediate superclass: '" +
                                delegate.getName(unit) +
                                "' is not a constructor of '" +
                                superclass.getName(unit) + "'");
                    }
                }
                else if (delegate instanceof Class) {
                    if (superclass.equals(delegate)) {
                        checkIsExactly(constructedType,
                                extendedType, type,
                                "type arguments must match type arguments in extended class expression");
                    }
                    else if (containingClass.equals(delegate)) {
                        checkIsExactly(constructedType,
                                containingClass.getType(), type,
                                "type arguments must be the type parameters of this class");
                    }
                    else {
                        type.addError("does not instantiate the immediate superclass: '" +
                                delegate.getName(unit) + "' is not '" +
                                superclass.getName(unit) + "'");
                    }
                }
            }
        }
    }

    private static boolean checkDirectSubtype(TypeDeclaration td,
            Node node, Type type) {
        boolean found = false;
        TypeDeclaration ctd = type.getDeclaration();
        if (td instanceof Interface) {
            for (Type st: ctd.getSatisfiedTypes()) {
                if (st!=null &&
                        st.resolveAliases()
                            .getDeclaration()
                            .equals(td)) {
                    found = true;
                }
            }
        }
        else if (td instanceof Class) {
            Type et = ctd.getExtendedType();
            if (et!=null &&
                    et.resolveAliases()
                        .getDeclaration()
                        .equals(td)) {
                found = true;
            }
        }
        if (!found) {
            node.addError("case type is not a direct subtype of enumerated type: " +
                    ctd.getName(node.getUnit()));
        }
        return found;
    }

    private String getCaseTypeExplanation(TypeDeclaration td,
            Type type) {
        String message = "case type must be a subtype of enumerated type";
        if (!td.getTypeParameters().isEmpty() &&
                type.getDeclaration().inherits(td)) {
            message += " for every type argument of the generic enumerated type";
        }
        return message;
    }

    private void checkExtensionOfMemberType(Node that,
            TypeDeclaration td, Type type) {
        Type qt = type.getQualifyingType();
        if (qt!=null && td instanceof ClassOrInterface) {
            Unit unit = that.getUnit();
            TypeDeclaration d = type.getDeclaration();
            if (d.isStaticallyImportable() ||
                    d instanceof Constructor) {
                checkExtensionOfMemberType(that, td, qt);
            }
            else {
                Scope s = td;
                while (s!=null) {
                    s = s.getContainer();
                    if (s instanceof TypeDeclaration) {
                        TypeDeclaration otd =
                                (TypeDeclaration) s;
                        if (otd.getType().isSubtypeOf(qt)) {
                            return;
                        }
                    }
                }
                that.addError("qualifying type '" + qt.asString(unit) +
                        "' of supertype '" + type.asString(unit) +
                        "' is not an outer type or supertype of any outer type of '" +
                        td.getName(unit) + "'");
            }
        }
    }

    private void checkSelfTypes(Tree.StaticType that,
            TypeDeclaration td, Type type) {
        if (!(td instanceof TypeParameter)) { //TODO: is this really ok?!
            List<TypeParameter> params =
                    type.getDeclaration()
                        .getTypeParameters();
            List<Type> args =
                    type.getTypeArgumentList();
            Unit unit = that.getUnit();
            for (int i=0; i<params.size(); i++) {
                TypeParameter param = params.get(i);
                if (param.isSelfType() && !args.isEmpty()) {
                    Type arg = args.get(i);
                    if (arg==null) {
                        arg = unit.getUnknownType();
                    }
                    TypeDeclaration std =
                            param.getSelfTypedDeclaration();
                    Type at;
                    TypeDeclaration mtd;
                    if (param.getContainer().equals(std)) {
                        at = td.getType();
                        mtd = td;
                    }
                    else {
                        //TODO: lots wrong here?
                        mtd = (TypeDeclaration)
                                td.getMember(std.getName(),
                                        null, false);
                        at = mtd==null ? null : mtd.getType();
                    }
                    if (at!=null && !at.isSubtypeOf(arg)) {
                        Type st = mtd.getSelfType();
                        if (st==null || !st.isExactly(arg)) {
                            String help = "";
                            TypeDeclaration atd = at.getDeclaration();
                            TypeDeclaration ad = arg.getDeclaration();
                            if (ad instanceof TypeParameter) {
                                TypeParameter tp = (TypeParameter) ad;
                                if (tp.getDeclaration().equals(td)) {
                                    help = " (try making '" + ad.getName() +
                                            "' a self type of '" + td.getName() + "')";
                                }
                            }
                            else if (ad instanceof Interface) {
                                help = " (try making " + message(atd) +
                                        " satisfy '" + ad.getName() + "')";
                            }
                            else if (ad instanceof Class && td instanceof Class) {
                                help = " (try making " + message(atd) +
                                        " extend '" + ad.getName() + "')";
                            }
                            that.addError("type argument does not satisfy self type constraint on type parameter '" +
                                    param.getName() + "' of '" +
                                    type.getDeclaration().getName(unit) + "': '" +
                                    arg.asString(unit) +
                                    "' is not a supertype or self type of " +
                                    message(atd) + help);
                        }
                    }
                }
            }
        }
    }

    private void checkSupertypeVarianceAnnotations(Tree.SimpleType et) {
        Tree.TypeArgumentList tal =
                et.getTypeArgumentList();
        if (tal!=null) {
            for (Tree.Type t: tal.getTypes()) {
                if (t instanceof Tree.StaticType) {
                    Tree.StaticType st = (Tree.StaticType) t;
                    Tree.TypeVariance variance =
                            st.getTypeVariance();
                    if (variance!=null) {
                        variance.addError("supertype expression may not specify variance");
                    }
                }
            }
        }
    }

    @Override
    public void visit(Tree.Enumerated that) {
        super.visit(that);
        Value v = that.getDeclarationModel();
        Scope container = v.getContainer();
        if (container instanceof Class) {
            Class cl = (Class) container;
            List<TypedDeclaration> caseValues =
                    cl.getCaseValues();
            if (caseValues!=null
                    && !caseValues.contains(v) &&
                    !cl.isAbstract()) {
                that.addError("value constructor does not occur in of clause of non-abstract enumerated class: '" +
                        v.getName() +
                        "' is not listed in the of clause of '" +
                        cl.getName() + "'");
            }
        }
    }

    @Override
    public void visit(Tree.Constructor that) {
        super.visit(that);
        Constructor c = that.getConstructor();
        Scope container =
                c.getContainer();
        if (container instanceof Class) {
            Class cl = (Class) container;
            List<TypedDeclaration> caseValues =
                    cl.getCaseValues();
            if (caseValues!=null &&
                    !c.isAbstract() &&
                    !cl.isAbstract()) {
                that.addError("non-abstract enumerated class may not have non-partial callable constructor");
            }
        }
    }

}


text:
using System;
using System.IO;
using System.IO.Packaging;

public class Runner
{
    public string PackageDirectory;
    string nuspecPath;

    public Action<string> WriteLog = x => { };

    public void Execute()
    {
        GetNuspecPath();

        var packageProperties = PackagePropertyReader.GetPackageProperties(nuspecPath);
        var nupkgPath = Path.Combine(PackageDirectory, string.Format("{0}.{1}.nupkg", packageProperties.Id, packageProperties.Version));
        File.Delete(nupkgPath);

        using (var package = Package.Open(nupkgPath, FileMode.CreateNew))
        {
            WriteManifest(package, nuspecPath);
            WriteFiles(package);
            WriteMetadata(packageProperties, package);
        }
    }

    static void WriteMetadata(PackageProperty packageProperties, Package package)
    {
        package.PackageProperties.Creator = packageProperties.Authors;
        package.PackageProperties.Description = packageProperties.Description;
        package.PackageProperties.Identifier = packageProperties.Id;
        package.PackageProperties.Version = packageProperties.Version;
        package.PackageProperties.Language = packageProperties.Language;
        package.PackageProperties.Keywords = packageProperties.Tags;
    }

    void GetNuspecPath()
    {
        var strings = Directory.GetFiles(PackageDirectory, "*.nuspec");
        if (strings.Length == 0)
        {
            throw new ExpectedException(string.Format("Could not find a .nuspec file in '{0}'.", PackageDirectory));
        }
        if (strings.Length > 1)
        {
            throw new ExpectedException(string.Format("Found more than 1 .nuspec files in '{0}'.", PackageDirectory));
        }
        nuspecPath = strings[0];
    }

    void WriteFiles(Package package)
    {
        foreach (var entry in Directory.EnumerateFiles(PackageDirectory, "*", SearchOption.AllDirectories))
        {
            if (entry.EndsWith(".nuspec"))
            {
                continue;
            }
            if (entry.EndsWith(".nupkg"))
            {
                continue;
            }
            using (Stream stream = File.OpenRead(entry))
            {
                CreatePart(package, entry, stream);
            }
        }
    }

    void CreatePart(Package package, string filePath, Stream sourceStream)
    {

        filePath = filePath.Replace(PackageDirectory, "").TrimStart('\\');
        var uri = PackUriHelper.CreatePartUri(new Uri(Uri.EscapeDataString(filePath), UriKind.Relative));
        var packagePart = package.CreatePart(uri, "application/octet", CompressionOption.Maximum);
        using (var stream = packagePart.GetStream())
        {
            sourceStream.CopyTo(stream);
        }
    }

    static void WriteManifest(Package package, string nuspecPath)
    {
        var uri = PackUriHelper.CreatePartUri(new Uri(Uri.EscapeDataString(Path.GetFileName(nuspecPath)), UriKind.Relative));

        // Create the manifest relationship
        package.CreateRelationship(uri, TargetMode.Internal, "http://schemas.microsoft.com/packaging/2010/07/manifest");

        // Create the part
        var packagePart = package.CreatePart(uri, "application/octet", CompressionOption.Maximum);

        using (var stream = packagePart.GetStream())
        using (var fileStream = File.OpenRead(nuspecPath))
        {
            fileStream.CopyTo(stream);
        }
    }

}

redpajama_set_name: RedPajamaGithub


text:
module Azure::Network::Mgmt::V2016_06_01
  module Models
    #
    # Backend address pool settings of application gateway
    #
    class ApplicationGatewayBackendHttpSettings < SubResource

      include MsRestAzure

      # @return [Integer] Port
      attr_accessor :port

      # @return [ApplicationGatewayProtocol] Protocol. Possible values include:
      # 'Http', 'Https'
      attr_accessor :protocol

      # @return [ApplicationGatewayCookieBasedAffinity] Cookie affinity.
      # Possible values include: 'Enabled', 'Disabled'
      attr_accessor :cookie_based_affinity

      # @return [Integer] Request timeout
      attr_accessor :request_timeout

      # @return [SubResource] Probe resource of application gateway
      attr_accessor :probe

      # @return [Array<SubResource>] Array of references to Application Gateway
      # Authentication Certificates
      attr_accessor :authentication_certificates

      # @return [String] Provisioning state of the backend http settings
      # resource Updating/Deleting/Failed
      attr_accessor :provisioning_state

      # @return [String] Name of the resource that is unique within a resource
      # group. This name can be used to access the resource
      attr_accessor :name

      # @return [String] A unique read-only string that changes whenever the
      # resource is updated
      attr_accessor :etag

      #
      # Mapper for ApplicationGatewayBackendHttpSettings class as Ruby Hash.
      # This will be used for serialization/deserialization.
      #
      def self.mapper()
        {
          client_side_validation: true,
          required: false,
          serialized_name: 'ApplicationGatewayBackendHttpSettings',
          type: {
            name: 'Composite',
            class_name: 'ApplicationGatewayBackendHttpSettings',
            model_properties: {
              id: {
                client_side_validation: true,
                required: false,
                serialized_name: 'id',
                type: {
                  name: 'String'
                }
              },
              port: {
                client_side_validation: true,
                required: false,
                serialized_name: 'properties.port',
                type: {
                  name: 'Number'
                }
              },
              protocol: {
                client_side_validation: true,
                required: false,
                serialized_name: 'properties.protocol',
                type: {
                  name: 'String'
                }
              },
              cookie_based_affinity: {
                client_side_validation: true,
                required: false,
                serialized_name: 'properties.cookieBasedAffinity',
                type: {
                  name: 'String'
                }
              },
              request_timeout: {
                client_side_validation: true,
                required: false,
                serialized_name: 'properties.requestTimeout',
                type: {
                  name: 'Number'
                }
              },
              probe: {
                client_side_validation: true,
                required: false,
                serialized_name: 'properties.probe',
                type: {
                  name: 'Composite',
                  class_name: 'SubResource'
                }
              },
              authentication_certificates: {
                client_side_validation: true,
                required: false,
                serialized_name: 'properties.authenticationCertificates',
                type: {
                  name: 'Sequence',
                  element: {
                      client_side_validation: true,
                      required: false,
                      serialized_name: 'SubResourceElementType',
                      type: {
                        name: 'Composite',
                        class_name: 'SubResource'
                      }
                  }
                }
              },
              provisioning_state: {
                client_side_validation: true,
                required: false,
                serialized_name: 'properties.provisioningState',
                type: {
                  name: 'String'
                }
              },
              name: {
                client_side_validation: true,
                required: false,
                serialized_name: 'name',
                type: {
                  name: 'String'
                }
              },
              etag: {
                client_side_validation: true,
                required: false,
                serialized_name: 'etag',
                type: {
                  name: 'String'
                }
              }
            }
          }
        }
      end
    end
  end
end


text:
public class LightOffCommand implements Command {
    Light light;

    public LightOffCommand(Light light) {
        this.light = light;
    }

    public void execute() {
        light.off();
    }
}


text:
package org.drools.core.common;

import org.drools.core.reteoo.EntryPointNode;
import org.drools.core.reteoo.ReteooBuilder;
import org.drools.core.reteoo.RuleRemovalContext;
import org.drools.core.reteoo.builder.BuildContext;
import org.drools.core.spi.RuleComponent;
import org.kie.api.definition.rule.Rule;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;

/**
 * The base class for all Rete nodes.
 */
public abstract class BaseNode
    implements
    NetworkNode {

    protected int                      id;
    protected RuleBasePartitionId      partitionId;
    protected boolean                  partitionsEnabled;
    protected Map<Rule, RuleComponent> associations;
    private   boolean                  streamMode;

    public BaseNode() {

    }

    /**
     * All nodes have a unique id, set in the constructor.
     *
     * @param id
     *      The unique id
     */
    public BaseNode(final int id,
                    final RuleBasePartitionId partitionId,
                    final boolean partitionsEnabled) {
        super();
        this.id = id;
        this.partitionId = partitionId;
        this.partitionsEnabled = partitionsEnabled;
        this.associations = new HashMap<Rule, RuleComponent>();
    }

    @SuppressWarnings("unchecked")
    public void readExternal(ObjectInput in) throws IOException,
                                            ClassNotFoundException {
        id = in.readInt();
        partitionId = (RuleBasePartitionId) in.readObject();
        partitionsEnabled = in.readBoolean();
        associations = (Map<Rule, RuleComponent>) in.readObject();
        streamMode = in.readBoolean();
    }

    public void writeExternal(ObjectOutput out) throws IOException {
        out.writeInt( id );
        out.writeObject( partitionId );
        out.writeBoolean( partitionsEnabled );
        out.writeObject( associations );
        out.writeBoolean( streamMode );
    }

    /* (non-Javadoc)
     * @see org.kie.spi.ReteooNode#getId()
     */
    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public boolean isStreamMode() {
        return this.streamMode;
    }

    protected void setStreamMode(boolean streamMode) {
        this.streamMode = streamMode;
    }

    public void attach() {
        attach(null);
    }

    /**
     * Attaches the node into the network. Usually to the parent ObjectSource or TupleSource
     */
    public abstract void attach(BuildContext context);

    /**
     * A method that is called for all nodes whose network below them
     * changed, after the change is complete, providing them with an oportunity
     * for state update
     */
    public abstract void networkUpdated(UpdateContext updateContext);

    public void remove(RuleRemovalContext context,
                       ReteooBuilder builder,
                       InternalWorkingMemory[] workingMemories) {
        this.removeAssociation( context.getRule() );
        doRemove( context,
                  builder,
                  workingMemories );
        if ( !this.isInUse() && !(this instanceof EntryPointNode) ) {
            builder.getIdGenerator().releaseId( this.getId() );
        }
    }

    /**
     * Removes the node from teh network. Usually from the parent ObjectSource or TupleSource
     */
    protected abstract void doRemove(RuleRemovalContext context,
                                     ReteooBuilder builder,
                                     InternalWorkingMemory[] workingMemories);

    /**
     * Returns true in case the current node is in use (is referenced by any other node)
     */
    public abstract boolean isInUse();

    /**
     * The hashCode return is simply the unique id of the node. It is expected that base classes will also implement equals(Object object).
     */
    public int hashCode() {
        return this.id;
    }

    public String toString() {
        return "[" + this.getClass().getSimpleName() + "(" + this.id + ")]";
    }

    /**
     * Returns the partition ID for which this node belongs to
     */
    public RuleBasePartitionId getPartitionId() {
        return this.partitionId;
    }

    /**
     * Sets the partition this node belongs to
     */
    public void setPartitionId(final RuleBasePartitionId partitionId) {
        this.partitionId = partitionId;
    }

    /**
     * Creates an association between this node and the rule + rule component
     * that caused the creation of this node. Since nodes might be shared,
     * there might be more than one source for each node.
     */
    public void addAssociation( Rule rule, RuleComponent component ) {
        this.associations.put( rule, component );
    }

    /**
     * Returns the map of associations for this node
     */
    public Map<Rule, RuleComponent> getAssociations() {
        return this.associations;
    }

    /**
     * Removes the association to the given rule from the
     * associations map.
     */
    public void removeAssociation( Rule rule ) {
        this.associations.remove(rule);
    }
}


text:
from django.core.management.base import BaseCommand, CommandError
from driver27.models import Driver, Team, Seat

import sys
if sys.version_info < (3, 0):
    try:
        import unicodecsv as csv
    except ImportError:
        import csv
else:
    import csv

class Command(BaseCommand):
    help = 'Export seats to csv'

    def get_config(self, export_attr):
        if export_attr == 'drivers':
            fieldnames = ['id', 'first_name', 'last_name', 'country', 'year_of_birth']
            export_cls = Driver
        elif export_attr == 'teams':
            fieldnames = ['id', 'name', 'full_name', 'country']
            export_cls = Team
        else:
            fieldnames = ['id', 'driver_id', 'driver__last_name', 'driver__first_name', 'team_id', 'team__name']
            export_cls = Seat
        objects = list(export_cls.objects.values(*fieldnames))
        return {'fieldnames': fieldnames, 'objects': objects}

    def add_arguments(self, parser):
        parser.add_argument('csv',)
        parser.add_argument(
            '--export',
            default='seats',
            help='By default, export seats. Options: seats, drivers, teams',
        )

    def handle(self, *args, **options):

        with open(options['csv'], 'wb') as csvfile:
            export_config = self.get_config(options['export'])
            writer = csv.DictWriter(csvfile, fieldnames=export_config['fieldnames'])
            writer.writeheader()

            for entry in export_config['objects']:
                writer.writerow(entry)


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Syn. pl. 2(2):475. 1807

#### Original name
null

### Remarks
null


text:
layout: post
title: "LESS, strict math, and calc"
excerpt:
tags:
  - css
  - less
---

There is a really helpful option for performing calculations in CSS called calc.
Calc lets you perform arithmetic operations on css values in your code. This can
be really useful if for example you want the width of one of your divs to be 30%
plus ten pixels. This can be done rather easily with calc like so:

    width: calc(30% + 10px);

However when using a preprocessor for CSS such as LESS this is not always as
straightforward as the above. LESS by default has strict math defaulted to off
(this is true at the time of writing but the LESS team are considering changing
  the default to on) with this option on LESS will only try and process all maths
  in the CSS which is inside unnecessary parenthesis, so in order to process the
  above you would need to write it as so:

     width: calc((30% + 10px));

Alternatively, and the approach I personally take is to escape the value, this
way everything inside the calc will be defined as a string until it is
evaluated by the client.

    width: calc(~"30% + 10px");

The nice thing about this is that you can insert LESS variables into the string

    @padding = 10px;
    width: calc(~"30% + @{padding}");


text:
layout: post
date: 2019-10-22 22:00:14 +0000
title: Digital preservation at Wellcome Collection
summary: Slides from a presentation about our processes, practices, and tools.
link: https://stacks.wellcomecollection.org/digital-preservation-at-wellcome-3f86b423047
tags: wellcome-collection digital-preservation
index:
  image: /images/2019/glam_cam_card.jpg
  tint_color: "#837252"
---

Last week I gave a short talk in Cambridge about digital preservation at Wellcome.
It was a quick overview of our processes, practices, and the tools we use.

We can think of a digital archive in three step:

1.  Production.
    How do we choose things to store in the archive?
2.  Storage.
    How do we keep the digital files safe?
3.  Retrieval.
    When somebody wants to see something in the archive, how do we present it?

My talk was a brief overview of each step, and how we're doing them.
If you'd like to read my notes, I've posted a text version of the talk on Stacks (a site where we write about digital happenings at Wellcome Collection).
Even if you don't work in digital preservation, I hope it makes sense and gives you a brief flavour of what I do for a day job.


text:
namespace DLaB.Xrm.Entities
{

	[System.Runtime.Serialization.DataContractAttribute()]
	[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "8.0.1.7297")]
	public enum msdyn_PostAlbumState
	{

		[System.Runtime.Serialization.EnumMemberAttribute()]
		Active = 0,

		[System.Runtime.Serialization.EnumMemberAttribute()]
		Inactive = 1,
	}

	/// <summary>
	/// Contains user profile images that are stored as attachments and displayed in posts.
	/// </summary>
	[System.Runtime.Serialization.DataContractAttribute()]
	[Microsoft.Xrm.Sdk.Client.EntityLogicalNameAttribute("msdyn_postalbum")]
	[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "8.0.1.7297")]
	public partial class msdyn_PostAlbum : Microsoft.Xrm.Sdk.Entity, System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged
	{

		public struct Fields
		{
			public const string CreatedBy = "createdby";
			public const string CreatedOn = "createdon";
			public const string CreatedOnBehalfBy = "createdonbehalfby";
			public const string ImportSequenceNumber = "importsequencenumber";
			public const string ModifiedBy = "modifiedby";
			public const string ModifiedOn = "modifiedon";
			public const string ModifiedOnBehalfBy = "modifiedonbehalfby";
			public const string msdyn_name = "msdyn_name";
			public const string msdyn_PostAlbumId = "msdyn_postalbumid";
			public const string Id = "msdyn_postalbumid";
			public const string OverriddenCreatedOn = "overriddencreatedon";
			public const string OwnerId = "ownerid";
			public const string OwningBusinessUnit = "owningbusinessunit";
			public const string OwningTeam = "owningteam";
			public const string OwningUser = "owninguser";
			public const string statecode = "statecode";
			public const string statuscode = "statuscode";
			public const string TimeZoneRuleVersionNumber = "timezoneruleversionnumber";
			public const string UTCConversionTimeZoneCode = "utcconversiontimezonecode";
			public const string VersionNumber = "versionnumber";
			public const string business_unit_msdyn_postalbum = "business_unit_msdyn_postalbum";
			public const string lk_msdyn_postalbum_createdby = "lk_msdyn_postalbum_createdby";
			public const string lk_msdyn_postalbum_createdonbehalfby = "lk_msdyn_postalbum_createdonbehalfby";
			public const string lk_msdyn_postalbum_modifiedby = "lk_msdyn_postalbum_modifiedby";
			public const string lk_msdyn_postalbum_modifiedonbehalfby = "lk_msdyn_postalbum_modifiedonbehalfby";
			public const string team_msdyn_postalbum = "team_msdyn_postalbum";
			public const string user_msdyn_postalbum = "user_msdyn_postalbum";
		}

		/// <summary>
		/// Default Constructor.
		/// </summary>
		[System.Diagnostics.DebuggerNonUserCode()]
		public msdyn_PostAlbum() :
				base(EntityLogicalName)
		{
		}

		public const string EntityLogicalName = "msdyn_postalbum";

		public const int EntityTypeCode = 10000;

		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging;

		[System.Diagnostics.DebuggerNonUserCode()]
		private void OnPropertyChanged(string propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
			}
		}

		[System.Diagnostics.DebuggerNonUserCode()]
		private void OnPropertyChanging(string propertyName)
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, new System.ComponentModel.PropertyChangingEventArgs(propertyName));
			}
		}

		/// <summary>
		/// Unique identifier of the user who created the record.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdby")]
		public Microsoft.Xrm.Sdk.EntityReference CreatedBy
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("createdby");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("CreatedBy");
				this.SetAttributeValue("createdby", value);
				this.OnPropertyChanged("CreatedBy");
			}
		}

		/// <summary>
		/// Date and time when the record was created.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdon")]
		public System.Nullable<System.DateTime> CreatedOn
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<System.DateTime>>("createdon");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("CreatedOn");
				this.SetAttributeValue("createdon", value);
				this.OnPropertyChanged("CreatedOn");
			}
		}

		/// <summary>
		/// Unique identifier of the delegate user who created the record.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdonbehalfby")]
		public Microsoft.Xrm.Sdk.EntityReference CreatedOnBehalfBy
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("createdonbehalfby");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("CreatedOnBehalfBy");
				this.SetAttributeValue("createdonbehalfby", value);
				this.OnPropertyChanged("CreatedOnBehalfBy");
			}
		}

		/// <summary>
		/// Sequence number of the import that created this record.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("importsequencenumber")]
		public System.Nullable<int> ImportSequenceNumber
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<int>>("importsequencenumber");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("ImportSequenceNumber");
				this.SetAttributeValue("importsequencenumber", value);
				this.OnPropertyChanged("ImportSequenceNumber");
			}
		}

		/// <summary>
		/// Unique identifier of the user who modified the record.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedby")]
		public Microsoft.Xrm.Sdk.EntityReference ModifiedBy
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("modifiedby");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("ModifiedBy");
				this.SetAttributeValue("modifiedby", value);
				this.OnPropertyChanged("ModifiedBy");
			}
		}

		/// <summary>
		/// Date and time when the record was modified.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedon")]
		public System.Nullable<System.DateTime> ModifiedOn
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<System.DateTime>>("modifiedon");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("ModifiedOn");
				this.SetAttributeValue("modifiedon", value);
				this.OnPropertyChanged("ModifiedOn");
			}
		}

		/// <summary>
		/// Unique identifier of the delegate user who modified the record.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedonbehalfby")]
		public Microsoft.Xrm.Sdk.EntityReference ModifiedOnBehalfBy
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("modifiedonbehalfby");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("ModifiedOnBehalfBy");
				this.SetAttributeValue("modifiedonbehalfby", value);
				this.OnPropertyChanged("ModifiedOnBehalfBy");
			}
		}

		/// <summary>
		/// The name of the custom entity.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("msdyn_name")]
		public string msdyn_name
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<string>("msdyn_name");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_name");
				this.SetAttributeValue("msdyn_name", value);
				this.OnPropertyChanged("msdyn_name");
			}
		}

		/// <summary>
		/// Unique identifier for entity instances
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("msdyn_postalbumid")]
		public System.Nullable<System.Guid> msdyn_PostAlbumId
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<System.Guid>>("msdyn_postalbumid");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_PostAlbumId");
				this.SetAttributeValue("msdyn_postalbumid", value);
				if (value.HasValue)
				{
					base.Id = value.Value;
				}
				else
				{
					base.Id = System.Guid.Empty;
				}
				this.OnPropertyChanged("msdyn_PostAlbumId");
			}
		}

		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("msdyn_postalbumid")]
		public override System.Guid Id
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return base.Id;
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.msdyn_PostAlbumId = value;
			}
		}

		/// <summary>
		/// Date and time that the record was migrated.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("overriddencreatedon")]
		public System.Nullable<System.DateTime> OverriddenCreatedOn
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<System.DateTime>>("overriddencreatedon");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("OverriddenCreatedOn");
				this.SetAttributeValue("overriddencreatedon", value);
				this.OnPropertyChanged("OverriddenCreatedOn");
			}
		}

		/// <summary>
		/// Owner Id
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ownerid")]
		public Microsoft.Xrm.Sdk.EntityReference OwnerId
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("ownerid");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("OwnerId");
				this.SetAttributeValue("ownerid", value);
				this.OnPropertyChanged("OwnerId");
			}
		}

		/// <summary>
		/// Unique identifier for the business unit that owns the record
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owningbusinessunit")]
		public Microsoft.Xrm.Sdk.EntityReference OwningBusinessUnit
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("owningbusinessunit");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("OwningBusinessUnit");
				this.SetAttributeValue("owningbusinessunit", value);
				this.OnPropertyChanged("OwningBusinessUnit");
			}
		}

		/// <summary>
		/// Unique identifier for the team that owns the record.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owningteam")]
		public Microsoft.Xrm.Sdk.EntityReference OwningTeam
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("owningteam");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("OwningTeam");
				this.SetAttributeValue("owningteam", value);
				this.OnPropertyChanged("OwningTeam");
			}
		}

		/// <summary>
		/// Unique identifier for the user that owns the record.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owninguser")]
		public Microsoft.Xrm.Sdk.EntityReference OwningUser
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("owninguser");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("OwningUser");
				this.SetAttributeValue("owninguser", value);
				this.OnPropertyChanged("OwningUser");
			}
		}

		/// <summary>
		/// Status of the Profile Album
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statecode")]
		public System.Nullable<Entities.msdyn_PostAlbumState> statecode
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				Microsoft.Xrm.Sdk.OptionSetValue optionSet = this.GetAttributeValue<Microsoft.Xrm.Sdk.OptionSetValue>("statecode");
				if ((optionSet != null))
				{
					return ((Entities.msdyn_PostAlbumState)(System.Enum.ToObject(typeof(Entities.msdyn_PostAlbumState), optionSet.Value)));
				}
				else
				{
					return null;
				}
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("statecode");
				if ((value == null))
				{
					this.SetAttributeValue("statecode", null);
				}
				else
				{
					this.SetAttributeValue("statecode", new Microsoft.Xrm.Sdk.OptionSetValue(((int)(value))));
				}
				this.OnPropertyChanged("statecode");
			}
		}

		/// <summary>
		/// Reason for the status of the Profile Album
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statuscode")]
		public Microsoft.Xrm.Sdk.OptionSetValue statuscode
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<Microsoft.Xrm.Sdk.OptionSetValue>("statuscode");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("statuscode");
				this.SetAttributeValue("statuscode", value);
				this.OnPropertyChanged("statuscode");
			}
		}

		/// <summary>
		/// For internal use only.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("timezoneruleversionnumber")]
		public System.Nullable<int> TimeZoneRuleVersionNumber
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<int>>("timezoneruleversionnumber");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("TimeZoneRuleVersionNumber");
				this.SetAttributeValue("timezoneruleversionnumber", value);
				this.OnPropertyChanged("TimeZoneRuleVersionNumber");
			}
		}

		/// <summary>
		/// Time zone code that was in use when the record was created.
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("utcconversiontimezonecode")]
		public System.Nullable<int> UTCConversionTimeZoneCode
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<int>>("utcconversiontimezonecode");
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("UTCConversionTimeZoneCode");
				this.SetAttributeValue("utcconversiontimezonecode", value);
				this.OnPropertyChanged("UTCConversionTimeZoneCode");
			}
		}

		/// <summary>
		///
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("versionnumber")]
		public System.Nullable<long> VersionNumber
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetAttributeValue<System.Nullable<long>>("versionnumber");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_ActivityPointers
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_ActivityPointers")]
		public System.Collections.Generic.IEnumerable<Entities.ActivityPointer> msdyn_postalbum_ActivityPointers
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.ActivityPointer>("msdyn_postalbum_ActivityPointers", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_ActivityPointers");
				this.SetRelatedEntities<Entities.ActivityPointer>("msdyn_postalbum_ActivityPointers", null, value);
				this.OnPropertyChanged("msdyn_postalbum_ActivityPointers");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_Annotations
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_Annotations")]
		public System.Collections.Generic.IEnumerable<Entities.Annotation> msdyn_postalbum_Annotations
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Annotation>("msdyn_postalbum_Annotations", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_Annotations");
				this.SetRelatedEntities<Entities.Annotation>("msdyn_postalbum_Annotations", null, value);
				this.OnPropertyChanged("msdyn_postalbum_Annotations");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_Appointments
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_Appointments")]
		public System.Collections.Generic.IEnumerable<Entities.Appointment> msdyn_postalbum_Appointments
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Appointment>("msdyn_postalbum_Appointments", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_Appointments");
				this.SetRelatedEntities<Entities.Appointment>("msdyn_postalbum_Appointments", null, value);
				this.OnPropertyChanged("msdyn_postalbum_Appointments");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_AsyncOperations
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_AsyncOperations")]
		public System.Collections.Generic.IEnumerable<Entities.AsyncOperation> msdyn_postalbum_AsyncOperations
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.AsyncOperation>("msdyn_postalbum_AsyncOperations", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_AsyncOperations");
				this.SetRelatedEntities<Entities.AsyncOperation>("msdyn_postalbum_AsyncOperations", null, value);
				this.OnPropertyChanged("msdyn_postalbum_AsyncOperations");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_BulkDeleteFailures
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_BulkDeleteFailures")]
		public System.Collections.Generic.IEnumerable<Entities.BulkDeleteFailure> msdyn_postalbum_BulkDeleteFailures
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.BulkDeleteFailure>("msdyn_postalbum_BulkDeleteFailures", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_BulkDeleteFailures");
				this.SetRelatedEntities<Entities.BulkDeleteFailure>("msdyn_postalbum_BulkDeleteFailures", null, value);
				this.OnPropertyChanged("msdyn_postalbum_BulkDeleteFailures");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_connections1
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_connections1")]
		public System.Collections.Generic.IEnumerable<Entities.Connection> msdyn_postalbum_connections1
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Connection>("msdyn_postalbum_connections1", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_connections1");
				this.SetRelatedEntities<Entities.Connection>("msdyn_postalbum_connections1", null, value);
				this.OnPropertyChanged("msdyn_postalbum_connections1");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_connections2
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_connections2")]
		public System.Collections.Generic.IEnumerable<Entities.Connection> msdyn_postalbum_connections2
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Connection>("msdyn_postalbum_connections2", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_connections2");
				this.SetRelatedEntities<Entities.Connection>("msdyn_postalbum_connections2", null, value);
				this.OnPropertyChanged("msdyn_postalbum_connections2");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_DuplicateBaseRecord
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_DuplicateBaseRecord")]
		public System.Collections.Generic.IEnumerable<Entities.DuplicateRecord> msdyn_postalbum_DuplicateBaseRecord
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.DuplicateRecord>("msdyn_postalbum_DuplicateBaseRecord", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_DuplicateBaseRecord");
				this.SetRelatedEntities<Entities.DuplicateRecord>("msdyn_postalbum_DuplicateBaseRecord", null, value);
				this.OnPropertyChanged("msdyn_postalbum_DuplicateBaseRecord");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_DuplicateMatchingRecord
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_DuplicateMatchingRecord")]
		public System.Collections.Generic.IEnumerable<Entities.DuplicateRecord> msdyn_postalbum_DuplicateMatchingRecord
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.DuplicateRecord>("msdyn_postalbum_DuplicateMatchingRecord", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_DuplicateMatchingRecord");
				this.SetRelatedEntities<Entities.DuplicateRecord>("msdyn_postalbum_DuplicateMatchingRecord", null, value);
				this.OnPropertyChanged("msdyn_postalbum_DuplicateMatchingRecord");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_Emails
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_Emails")]
		public System.Collections.Generic.IEnumerable<Entities.Email> msdyn_postalbum_Emails
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Email>("msdyn_postalbum_Emails", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_Emails");
				this.SetRelatedEntities<Entities.Email>("msdyn_postalbum_Emails", null, value);
				this.OnPropertyChanged("msdyn_postalbum_Emails");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_Faxes
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_Faxes")]
		public System.Collections.Generic.IEnumerable<Entities.Fax> msdyn_postalbum_Faxes
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Fax>("msdyn_postalbum_Faxes", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_Faxes");
				this.SetRelatedEntities<Entities.Fax>("msdyn_postalbum_Faxes", null, value);
				this.OnPropertyChanged("msdyn_postalbum_Faxes");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_Letters
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_Letters")]
		public System.Collections.Generic.IEnumerable<Entities.Letter> msdyn_postalbum_Letters
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Letter>("msdyn_postalbum_Letters", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_Letters");
				this.SetRelatedEntities<Entities.Letter>("msdyn_postalbum_Letters", null, value);
				this.OnPropertyChanged("msdyn_postalbum_Letters");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_MailboxTrackingFolders
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_MailboxTrackingFolders")]
		public System.Collections.Generic.IEnumerable<Entities.MailboxTrackingFolder> msdyn_postalbum_MailboxTrackingFolders
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.MailboxTrackingFolder>("msdyn_postalbum_MailboxTrackingFolders", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_MailboxTrackingFolders");
				this.SetRelatedEntities<Entities.MailboxTrackingFolder>("msdyn_postalbum_MailboxTrackingFolders", null, value);
				this.OnPropertyChanged("msdyn_postalbum_MailboxTrackingFolders");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_PhoneCalls
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_PhoneCalls")]
		public System.Collections.Generic.IEnumerable<Entities.PhoneCall> msdyn_postalbum_PhoneCalls
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.PhoneCall>("msdyn_postalbum_PhoneCalls", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_PhoneCalls");
				this.SetRelatedEntities<Entities.PhoneCall>("msdyn_postalbum_PhoneCalls", null, value);
				this.OnPropertyChanged("msdyn_postalbum_PhoneCalls");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_PrincipalObjectAttributeAccesses
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_PrincipalObjectAttributeAccesses")]
		public System.Collections.Generic.IEnumerable<Entities.PrincipalObjectAttributeAccess> msdyn_postalbum_PrincipalObjectAttributeAccesses
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.PrincipalObjectAttributeAccess>("msdyn_postalbum_PrincipalObjectAttributeAccesses", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_PrincipalObjectAttributeAccesses");
				this.SetRelatedEntities<Entities.PrincipalObjectAttributeAccess>("msdyn_postalbum_PrincipalObjectAttributeAccesses", null, value);
				this.OnPropertyChanged("msdyn_postalbum_PrincipalObjectAttributeAccesses");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_ProcessSession
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_ProcessSession")]
		public System.Collections.Generic.IEnumerable<Entities.ProcessSession> msdyn_postalbum_ProcessSession
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.ProcessSession>("msdyn_postalbum_ProcessSession", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_ProcessSession");
				this.SetRelatedEntities<Entities.ProcessSession>("msdyn_postalbum_ProcessSession", null, value);
				this.OnPropertyChanged("msdyn_postalbum_ProcessSession");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_RecurringAppointmentMasters
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_RecurringAppointmentMasters")]
		public System.Collections.Generic.IEnumerable<Entities.RecurringAppointmentMaster> msdyn_postalbum_RecurringAppointmentMasters
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.RecurringAppointmentMaster>("msdyn_postalbum_RecurringAppointmentMasters", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_RecurringAppointmentMasters");
				this.SetRelatedEntities<Entities.RecurringAppointmentMaster>("msdyn_postalbum_RecurringAppointmentMasters", null, value);
				this.OnPropertyChanged("msdyn_postalbum_RecurringAppointmentMasters");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_ServiceAppointments
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_ServiceAppointments")]
		public System.Collections.Generic.IEnumerable<Entities.ServiceAppointment> msdyn_postalbum_ServiceAppointments
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.ServiceAppointment>("msdyn_postalbum_ServiceAppointments", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_ServiceAppointments");
				this.SetRelatedEntities<Entities.ServiceAppointment>("msdyn_postalbum_ServiceAppointments", null, value);
				this.OnPropertyChanged("msdyn_postalbum_ServiceAppointments");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_SocialActivities
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_SocialActivities")]
		public System.Collections.Generic.IEnumerable<Entities.SocialActivity> msdyn_postalbum_SocialActivities
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.SocialActivity>("msdyn_postalbum_SocialActivities", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_SocialActivities");
				this.SetRelatedEntities<Entities.SocialActivity>("msdyn_postalbum_SocialActivities", null, value);
				this.OnPropertyChanged("msdyn_postalbum_SocialActivities");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_Tasks
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_Tasks")]
		public System.Collections.Generic.IEnumerable<Entities.Task> msdyn_postalbum_Tasks
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.Task>("msdyn_postalbum_Tasks", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_Tasks");
				this.SetRelatedEntities<Entities.Task>("msdyn_postalbum_Tasks", null, value);
				this.OnPropertyChanged("msdyn_postalbum_Tasks");
			}
		}

		/// <summary>
		/// 1:N msdyn_postalbum_UserEntityInstanceDatas
		/// </summary>
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("msdyn_postalbum_UserEntityInstanceDatas")]
		public System.Collections.Generic.IEnumerable<Entities.UserEntityInstanceData> msdyn_postalbum_UserEntityInstanceDatas
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntities<Entities.UserEntityInstanceData>("msdyn_postalbum_UserEntityInstanceDatas", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("msdyn_postalbum_UserEntityInstanceDatas");
				this.SetRelatedEntities<Entities.UserEntityInstanceData>("msdyn_postalbum_UserEntityInstanceDatas", null, value);
				this.OnPropertyChanged("msdyn_postalbum_UserEntityInstanceDatas");
			}
		}

		/// <summary>
		/// N:1 business_unit_msdyn_postalbum
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owningbusinessunit")]
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("business_unit_msdyn_postalbum")]
		public Entities.BusinessUnit business_unit_msdyn_postalbum
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntity<Entities.BusinessUnit>("business_unit_msdyn_postalbum", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("business_unit_msdyn_postalbum");
				this.SetRelatedEntity<Entities.BusinessUnit>("business_unit_msdyn_postalbum", null, value);
				this.OnPropertyChanged("business_unit_msdyn_postalbum");
			}
		}

		/// <summary>
		/// N:1 lk_msdyn_postalbum_createdby
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdby")]
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("lk_msdyn_postalbum_createdby")]
		public Entities.SystemUser lk_msdyn_postalbum_createdby
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_createdby", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("lk_msdyn_postalbum_createdby");
				this.SetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_createdby", null, value);
				this.OnPropertyChanged("lk_msdyn_postalbum_createdby");
			}
		}

		/// <summary>
		/// N:1 lk_msdyn_postalbum_createdonbehalfby
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdonbehalfby")]
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("lk_msdyn_postalbum_createdonbehalfby")]
		public Entities.SystemUser lk_msdyn_postalbum_createdonbehalfby
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_createdonbehalfby", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("lk_msdyn_postalbum_createdonbehalfby");
				this.SetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_createdonbehalfby", null, value);
				this.OnPropertyChanged("lk_msdyn_postalbum_createdonbehalfby");
			}
		}

		/// <summary>
		/// N:1 lk_msdyn_postalbum_modifiedby
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedby")]
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("lk_msdyn_postalbum_modifiedby")]
		public Entities.SystemUser lk_msdyn_postalbum_modifiedby
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_modifiedby", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("lk_msdyn_postalbum_modifiedby");
				this.SetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_modifiedby", null, value);
				this.OnPropertyChanged("lk_msdyn_postalbum_modifiedby");
			}
		}

		/// <summary>
		/// N:1 lk_msdyn_postalbum_modifiedonbehalfby
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedonbehalfby")]
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("lk_msdyn_postalbum_modifiedonbehalfby")]
		public Entities.SystemUser lk_msdyn_postalbum_modifiedonbehalfby
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_modifiedonbehalfby", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("lk_msdyn_postalbum_modifiedonbehalfby");
				this.SetRelatedEntity<Entities.SystemUser>("lk_msdyn_postalbum_modifiedonbehalfby", null, value);
				this.OnPropertyChanged("lk_msdyn_postalbum_modifiedonbehalfby");
			}
		}

		/// <summary>
		/// N:1 team_msdyn_postalbum
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owningteam")]
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("team_msdyn_postalbum")]
		public Entities.Team team_msdyn_postalbum
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntity<Entities.Team>("team_msdyn_postalbum", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("team_msdyn_postalbum");
				this.SetRelatedEntity<Entities.Team>("team_msdyn_postalbum", null, value);
				this.OnPropertyChanged("team_msdyn_postalbum");
			}
		}

		/// <summary>
		/// N:1 user_msdyn_postalbum
		/// </summary>
		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owninguser")]
		[Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("user_msdyn_postalbum")]
		public Entities.SystemUser user_msdyn_postalbum
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return this.GetRelatedEntity<Entities.SystemUser>("user_msdyn_postalbum", null);
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				this.OnPropertyChanging("user_msdyn_postalbum");
				this.SetRelatedEntity<Entities.SystemUser>("user_msdyn_postalbum", null, value);
				this.OnPropertyChanged("user_msdyn_postalbum");
			}
		}

		/// <summary>
		/// Constructor for populating via LINQ queries given a LINQ anonymous type
		/// <param name="anonymousType">LINQ anonymous type.</param>
		/// </summary>
		[System.Diagnostics.DebuggerNonUserCode()]
		public msdyn_PostAlbum(object anonymousType) :
				this()
		{
            foreach (var p in anonymousType.GetType().GetProperties())
            {
                var value = p.GetValue(anonymousType, null);
                var name = p.Name.ToLower();

                if (name.EndsWith("enum") && value.GetType().BaseType == typeof(System.Enum))
                {
                    value = new Microsoft.Xrm.Sdk.OptionSetValue((int) value);
                    name = name.Remove(name.Length - "enum".Length);
                }

                switch (name)
                {
                    case "id":
                        base.Id = (System.Guid)value;
                        Attributes["msdyn_postalbumid"] = base.Id;
                        break;
                    case "msdyn_postalbumid":
                        var id = (System.Nullable<System.Guid>) value;
                        if(id == null){ continue; }
                        base.Id = id.Value;
                        Attributes[name] = base.Id;
                        break;
                    case "formattedvalues":
                        // Add Support for FormattedValues
                        FormattedValues.AddRange((Microsoft.Xrm.Sdk.FormattedValueCollection)value);
                        break;
                    default:
                        Attributes[name] = value;
                        break;
                }
            }
		}

		[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statuscode")]
		public virtual msdyn_PostAlbum_StatusCode? statuscodeEnum
		{
			[System.Diagnostics.DebuggerNonUserCode()]
			get
			{
				return ((msdyn_PostAlbum_StatusCode?)(EntityOptionSetEnum.GetEnum(this, "statuscode")));
			}
			[System.Diagnostics.DebuggerNonUserCode()]
			set
			{
				statuscode = value.HasValue ? new Microsoft.Xrm.Sdk.OptionSetValue((int)value) : null;
			}
		}
	}
}


text:
'use strict';

/* App Module */
var mediaApp = angular.module('mediaApp', ['ionic','ngResource','wu.masonry'])

mediaApp.config(function($stateProvider, $urlRouterProvider) {

    $stateProvider
        .state('menu', {
            url: "/menu",
            abstract: true,
            templateUrl: "menu.html"

        })
        .state('menu.home', {
            url: "/home",
            views: {
                'menuContent' :{
                    templateUrl: "views/home.html",
                    controller: "HomeCtrl"
                }
            }
        })
        .state('menu.search', {
            url: "/search",
            views: {
                'menuContent' :{
                    templateUrl: "views/search.html",
                    controller: "SearchCtrl"
                }
            }
        })

        .state('menu.settings', {
            url: "/settings",
            views: {
                'menuContent' :{
                    templateUrl: "views/settings.html",
                    controller: "SettingsCtrl"
                }
            }
        })
        .state('menu.about', {
            url: "/about",
            views: {
                'menuContent' :{
                    templateUrl: "views/about.html",
                    controller: "AboutCtrl"
                }
            }
        });

    $urlRouterProvider.otherwise("/menu/home");
})


text:
#######################DISA INFORMATION###############################
#Group ID (Vulid): V-11941-2
#Group Title: System Baseline Must Contain Cryptographic Hashes
#Rule ID: SV-12442-2r6_rule
#Severity: CAT II
#Rule Version (STIG-ID): GEN000140-2
#Rule Title: A file integrity baseline including cryptographic hashes
#must be created and maintained.
#
#Vulnerability Discussion: A file integrity baseline is a collection
#of file metadata which is to evaluate the integrity of the system.
#A minimal baseline must contain metadata for all device files,
#setuid files, setgid files, system libraries, system binaries, and
#system configuration files. The minimal metadata must consist of
#the mode, owner, group owner, and modification times. For regular
#files, metadata must also include file size and a cryptographic
#hash of the file's contents.
#
#Responsibility: System Administrator
#IAControls: DCSW-1
#
#Check Content:
#Determine if a file integrity baseline, which includes
#cryptographic hashes, has been created for the system.
#
#Procedure:
#
#If the file integrity baseline contains no cryptographic hashes,
#this is a finding.
#
#
#
#Fix Text: Create a file integrity baseline, including cryptographic
#hashes, for the system.
#######################DISA INFORMATION###############################

#Global Variables#
PDI=GEN000140-2

#Start-Lockdown